28-05-2013, 11:52 AM
Introduction to Java Programming
Introduction to Java.docx (Size: 282.76 KB / Downloads: 21)
Introduction to Java
History
Java is a programming language created by James Gosling from Sun Microsystems in 1991. The first publicly available version of Java (Java 1.0) was released in 1995.
Over time new enhanced versions of Java have been released. The current version of Java is Java 1.7 which is also known as Java 7.
From the Java programming language the Java platform evolved. The Java platform allows that the program code is written in other languages than the Java programming language and still runs on the Java virtual machine.
Java Virtual machine
The Java virtual machine (JVM) is a software implementation of a computer that executes programs like a real machine.
The Java virtual machine is written specifically for a specific operating system, e.g. for Linux a special implementation is required as well as for Windows.
Java programs are compiled by the Java compiler into so-called bytecode. The Java virtual machine interprets this bytecode and executes the Java program.
Java Runtime Environment vs. Java Development Kit
Java comes in two flavors, the Java Runtime Environment (JRE) and the Java Development Kit (JDK).
The Java runtime environment (JRE) consists of the JVM and the Java class libraries and contains the necessary functionality to start Java programs.
The JDK contains in addition the development tools necessary to create Java programs. The JDK consists therefore of a Java compiler, the Java virtual machine, and the Java class libraries.
Development Process with Java
The programmer writes Java source code in a text editor which supports plain text. Normally the programmer uses an Integrated Development Environment (IDE) for programming. An IDE supports the programmer in the task of writing code, e.g. it provides auto-formating of the source code, highlighting of the important keywords, etc.
At some point the programmer (or the IDE) calls the Java compiler (javac). The Java compiler creates the bytecode instructions. . These instructions are stored in .class files and can be executed by the Java Virtual Machine.
Your first Java program
Write source code
The following Java program is developed under Microsoft Windows. The process on other operating system should be similar but is not covered in this description.
Select a new directory which will contain your Java code. I will use the c:\temp\java which will be called javadir in the following description.
Open a text editor which supports plain text, e.g. Notepad under Windows and write the following source code. You can start Notepad via Start → Run → Notepad and by pressing enter.
Integrated Development Environment
The previous chapter explained how to create and compile a Java program on the command line. A Java Integrated Development Environment (IDE) provides lots of ease of use functionality for creating java programs. There are other very powerful IDE's available, for example the Eclipse IDE. .
For an introduction on how to use the Eclipse IDE please see Eclipse IDE Tutorial.
In the following I will say "Create a Java project SomeName". This will refer to creating an Eclipse Java project. If you are using a different IDE please follow the required steps in this IDE.