My First In Java
()
About this ebook
Concepts are discussed chapter by chapter in progressive order. It is suggested that student answers chapter exercises to gauge the understanding of the topics discussed.
Students may download all sample programs with the provided link.
YouTube video links were also provided if one opts to learn the topics through video presentations.
Object-oriented programming(OOP) is not yet discussed on this book. Though java is an OOP language, the author believes OOP concepts are too broad or too early to discuss for students who are just starting to learn programming.
Related to My First In Java
Related ebooks
Java: Beginner's Guide to Programming Code with Java Rating: 0 out of 5 stars0 ratingsBeginning Mobile Application Development in the Cloud Rating: 0 out of 5 stars0 ratingsCrystal Clear Java: 1St Edition Rating: 0 out of 5 stars0 ratingsJAVA: Java Programming for beginners teaching you basic to advanced JAVA programming skills! Rating: 0 out of 5 stars0 ratingsJava with TDD from the Beginning Rating: 0 out of 5 stars0 ratingsPrinciples of Programming: Java Level 1 Rating: 0 out of 5 stars0 ratingsJavaScript Mobile Application Development Rating: 0 out of 5 stars0 ratingsJAVA for Beginner's Crash Course: Java for Beginners Guide to Program Java, jQuery, & Java Programming Rating: 4 out of 5 stars4/5Java: Beginner's Guide to Programming Code with Java: Java Computer Programming Rating: 0 out of 5 stars0 ratings(Part 1) Absolute Beginner: Java 4 Selenium WebDriver: Come Learn How To Program For Automation Testing Rating: 5 out of 5 stars5/5Introduction to programming in C, a practical approach. Rating: 0 out of 5 stars0 ratingsJAVA Programming Simplified: From Novice to Professional - Start at the Beginning and Learn the World of Java Rating: 0 out of 5 stars0 ratings100+ Solutions in Java: A Hands-On Introduction to Programming in Java (English Edition) Rating: 0 out of 5 stars0 ratings100+ Solutions in Java - 2nd Edition: Everything you need to know to develop Java applications (English Edition) Rating: 0 out of 5 stars0 ratingsBasic Java Programming for Kids and Beginners Rating: 0 out of 5 stars0 ratingsJava Programming : The Complete Beginners Guide Rating: 0 out of 5 stars0 ratingsJava and Java EE Interview Preparations Rating: 0 out of 5 stars0 ratingsJava: A complete practical solution Rating: 0 out of 5 stars0 ratingsJava Web Developer A Complete Guide Rating: 0 out of 5 stars0 ratingsProgramming Constructs in Java Rating: 1 out of 5 stars1/5Java: Advanced Guide to Programming Code with Java Rating: 0 out of 5 stars0 ratingsJava: Tips and Tricks to Programming Code with Java Rating: 0 out of 5 stars0 ratingsUltimate Flutter Handbook: Learn Cross-Platform App Development with Visually Stunning UIs and Real-World Projects Rating: 0 out of 5 stars0 ratingsParallel and High Performance Programming with Python Rating: 0 out of 5 stars0 ratingsAutomating Software Tests Using Selenium Rating: 0 out of 5 stars0 ratingsJava servlet Second Edition Rating: 0 out of 5 stars0 ratingsDeveloping Web Applications with ASP.NET and C# Rating: 0 out of 5 stars0 ratings
Computers For You
Data Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5Mastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 4 out of 5 stars4/5Algorithms to Live By: The Computer Science of Human Decisions Rating: 4 out of 5 stars4/5Python for Beginners: A Crash Course to Learn Python Programming in 1 Week Rating: 0 out of 5 stars0 ratingsStorytelling with Data: Let's Practice! Rating: 4 out of 5 stars4/5Creating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5Narrative Design for Indies: Getting Started Rating: 4 out of 5 stars4/5The Alignment Problem: How Can Machines Learn Human Values? Rating: 4 out of 5 stars4/5Python for Finance Cookbook: Over 50 recipes for applying modern Python libraries to financial data analysis Rating: 0 out of 5 stars0 ratingsBlack Holes: The Key to Understanding the Universe Rating: 5 out of 5 stars5/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5How Do I Do That In InDesign? Rating: 5 out of 5 stars5/5ITIL® 4 Essentials: Your essential guide for the ITIL 4 Foundation exam and beyond, second edition Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Get Into UX: A foolproof guide to getting your first user experience job Rating: 4 out of 5 stars4/5The Unaccountability Machine: Why Big Systems Make Terrible Decisions - and How The World Lost its Mind Rating: 0 out of 5 stars0 ratingsDjango Building Dynamic Website With Django : A Complete Step By Step Guide To Learn to Build Modern Web Application with a Python Rating: 0 out of 5 stars0 ratingsAdvances in Financial Machine Learning Rating: 5 out of 5 stars5/5Statistics Slam Dunk Rating: 0 out of 5 stars0 ratingsLearn SAP MM in 24 Hours Rating: 0 out of 5 stars0 ratingsBecoming a Data Head: How to Think, Speak, and Understand Data Science, Statistics, and Machine Learning Rating: 5 out of 5 stars5/5Deep Learning with PyTorch Rating: 5 out of 5 stars5/5Learn Algorithmic Trading: Build and deploy algorithmic trading systems and strategies using Python and advanced data analysis Rating: 0 out of 5 stars0 ratingsArtificial Intelligence: The Complete Beginner’s Guide to the Future of A.I. Rating: 4 out of 5 stars4/5
Reviews for My First In Java
0 ratings0 reviews
Book preview
My First In Java - Jeremias Esperanza
potential.
Chapter 1
An Introduction to Java
At the end of this chapter, you will be able to:
Know history that drove development of java;
Specify the developement stages of a java program;
Realize the importance of an IDE;
Install java compiler;
Install Eclipse IDE.
Java is a high-level programming language. High-level language means a program can be written in a human language that the computer machine can later on decipher and understand.
James Gosling and associates at Sun Microsystems, during the 1990s, started developing a programming language (PL) that will suit automation of household appliances (TV, VCRs, Refs, etc..). Oak was the original name they could think of for the PL only to realize there was already an existing name for that PL. The name Java was later on derived from a flavor of a coffee when they were sipping it from a coffee shop during those times.
The popularity of Java grew tremendously during the mid-1990s. It was also on those times internet is paving its way to mainstream computing. The timing of Java was perfect because applications can be developed using the PL without concerns on which platforms it will run. Soon the defacto language of choice of most software development companies is Java up to the present time. It is estimated that Java runs on 5.5 billion devices worldwide today.
Phases of a Java program
Java boasts its strengths in terms of portability. Once you write and compile, it will run on any platform a computer has. Platform means is the operating system used by a machine. Example of this is Windows, Linux, MacOS, Android, and many others.
How do we develop program in Java? The following are stages:
1. Write. A java program can be written in any text editor softwares such as MS Word (without the format codes), Notepad, Crimson Editor, Sidekick, etc. What you need is to supply a file extension name .java once you save the file. The file you have just saved will be the source code of a java program.
2. Compile. You can easily download for free from the internet the latest java development kit (JDK) that you may use in developing java programs. Together with the JDK is a program called javac.exe. This is the compiler of java.
What does a compiler do? Compiler checks the syntax or formats of the codes you have written on a java program. It will ensure that all the words you have written comply with the java statement commands. If errors are detected from your program, it will specify the line number on where the mistake/s took place. You need to correct those errors, and re-compile. You will only proceed on the next stage of the development if your program is error-free.
C1.StagesFigure C1.1 Phases of Java program
An error-free program compiled by the javac.exe produces a byte code file. Byte code is a machine-language codes that will be interpreted by a Java Virtual Machine (JVM). The codes are no longer expressed in a human language but with the codes the machine understands. Byte code file has an extension filename of .class. An example on how to compile a program in a command line is as follows (Hello is the name of the program):
javac Hello.java
3. Run. Along with the downloads of JDK is an interpreter called java.exe. An interpreter is used to serve as an interface so the processor of the machine can understand what your program wants to achieve once you run it. Please note that the byte code file (filename with the .class extension) is the one interpreted and not the original file you have written (filename with the .java extension). Below is an example on how to run a java byte code program on a command line:
java Hello
Role of IDE
Integrated Development Environment (IDE) is a software tool that will increase the development of a java program. You do not need to have an IDE to develop a java program. You need a text editor program, compiler, and interpreter to develop program.
Detection of errors are made earlier even the program is not yet compiled when you use an IDE. The IDE notifies a syntax error occurs in the command/statement or no declaration yet has made on a variable as the programmer types the program. It even suggests solutions on how to quick fix an error in the program. It also gives a hint on what available methods and parameters you could use for a particular command/statement.
The interface with the java compiler and interpreter is already done by an IDE. Running your program can easily be done with a push of a command button. It also includes a debugger on where you could trace the values of the variables. An IDE is a java solution tool rolled into one.
There are many popular IDEs available on where you could download for free. Examples of IDEs are Eclipse, Net Beans, among others.
Before we could write our first java programs, we need to install our java compiler that will convert our source program into an bytecode file that a machine can understand.
An Integrated Development Environment (IDE) is a software tool used by developers in writing, compiling, debugging, and running their programs. This is where Eclipse IDE is known for.
The following installation will guide us on how to download and install java compiler and Eclipse IDE on our computer.
Installing Java Compiler for Windows
Go to your browser.
Visit http://google.com
Type in the google search box: java jdk.
Click Java SE Downloads
C1.1Figure C1.2 Java sites to download compiler
5. Click the latest release. On this case it is the Java Platform (JDK) 7u6. (see Figure C1.3).
C1.2Figure C1.3 Java Development Kit to download
6. Click the Accept License Agreement.
C1.3Figure C1.4 Accept License Agreement
7. Underneath select the appropriate java compiler suited for your OS. On this case, we choose Windows X86 for the 16-bit Windows 7 OS.
C1.4Figure C1.5 Version to download
8. Wait for the download to complete. Double click the downloaded file (see Figure C1.6).
C1.5Figure C1.6 Version downloaded
9. On Windows 7 you will be prompted if the installer is allowed to make changes. Just click yes.
10. You will be prompted on the installation procedure. Accept the default settings. Just click Next.
C1.6Figure C1.7 Opening window prior to installation
C1.7Figure C1.8 Folder location on where to install
11. This is the last window when the installation is completed. Click Finish.
C1.8Figure C1.9 Final window after installation
Video presentation: Install compiler
Installing Eclipse IDE
1. Visit http://www.eclipse.org/downloads/
C1.9Figure C1.10 Choices of eclipse version
2. Depending on your computer OS, click the corresponding link (normally, XP is Windows 32 bit, Windows 7 is 32 or 64 bit). On my case, I’m using Windows 7, I will click Eclipse Classic 3.7.2 Windows 32 bit. Skip 3 if you are running under Windows OS.
3. If you are running a different OS (Linux or Mac OS), you may select it on the dropdown box. Just the same, click the bit version your OS supports.
C1.10Figure C1.11 Choose appropriate OS
4. You will be prompted to select the mirror location where downloads will come from. Click the suggested default site (green down arrow). Depending on the speed of your modem, this may take a while. Wait for the download to complete.
C1.11Figure C1.12 Mirror site of download
5. Double click the zip file to begin extraction of eclipse.
C1.12Figure C1.13 Eclipse downloaded installer
6. Click the Extract To commence.
C1.13Figure C1.14 WinRAR extraction of eclipse
7. Select (C:) Local Disk as the destination of our extraction. Click OK.
C1.14Figure C1.15 Folder location on where to install eclipse
8. After completing the extraction of the file, close the Winzip program.
9. Click. Start | My Computer
10. Double click (C:) Local Disk.
11. Double Click the Eclipse folder.
12. Right-click the Eclipse icon and Send To | Desktop to create a shortcut.
C1.15Figure C1.16 Shortcut icon for eclipse
Video presentation: Install Eclipse IDE
Chapter 2
Java First Programs
At the end of this chapter, you will be able to:
Write your first sets of java programs;
Familiarize with the terminator symbol semicolon;
Use comments, new line and tab characters;