Java is an object oriented programming language and computing platform that was first released by Sun Microsystems in early 1996 and has grown in popularity ever since. The Java language has gone through a lot of changes during its evolution and the table below outlines the major releases.
|Release Name And Date||Codename||Known As||≈ Number Of Classes|
|JDK 1.0 (January 23, 1996)||Oak||Java 1||250|
|JDK 1.1 (February 19, 1997)||Java 1||500|
|J2SE 1.2 (December 8, 1998)||Playground||Java 2||1600+|
|J2SE 1.3 (May 8, 2000)||Kestrel||Java 2||1800+|
|J2SE 1.4 (February 6, 2002)||Merlin||Java 2||2700+|
|J2SE 5.0 (September 30, 2004)||Tiger||Java 5.0||3200+|
|Java SE 6 (December 11, 2006)||Mustang||Java 6||3700+|
|Java SE 7 (July 28, 2011)||Dolphin||Java 7||3900+|
The release names in the table are somewhat confusing so lets go through them. In the first two versions the JDK stands for Java Developers Kit and these versions were knows as Java 1. With the release of J2SE 1.2, because the changes were so large this version through J2SE 5.0 were prefixed with J2SE (Java 2 Platform, Standard Edition). The J2 denoting Java 2 and the SE to distinguish the standard edition platform from J2EE (Java 2 Platform, Enterprise Edition) and J2ME (Java 2 Platform, Micro Edition). Things got even more confusing with the release of J2SE 5.0 which also included changes large enough that it became known as Java 5.0 even though in reality it was version 1.5. So Java 1.5, Java 5.0 and Java 5 all refer to this release (there was never a Java 3 or Java 4). From version Java SE 6 onwards the J2 prefix and the .0 suffix were dropped and versions were simply known as Java6, Java7 from then onwards. This section of the site is all about Java6 and we will be using this naming from now on.
So Why Use Java?
The Java programming language is platform independent and can be run in a wide variety of environments. This is achieved via the Java compiler which converts a document into Java bytecode, which is a highly optimized set of instructions designed to be executed by the Java run time system which is more commonly known as the Java Virtual Machine or JVM for short. In essence the JVM is an interpreter for the Java bytecode and as such, when implemented on a platform can run any Java bytecode on that platform. So although the implementation of the JVM may differ from platform to platform the underlying bytecode is always the same. This flexibility is what makes the Java language so portable.
The use of the JVM also makes the use of Java more secure as the JVM acts like a firewall between the application and a computer. All Java programs are under the control of the JVM and as such the JVM can stop adverse side effects propogating outside the system.
Concerns in early releases of Java over the speed the language runs at, because it is an interpreted language, have since subsided as the JVM has been streamlined and improved. The advantages of portability and security have placed Java at the top of the tree of object orientated programming languages and is why the language is used in so many diverse applications today.
In our first lesson on Java6 we download the latest JDK from the Oracle site and setup our environment. We then check that everything is working as it should by running a check to see if the Java compiler can be accessed from the command line.
Getting The Java Software Development Kit (SDK)
Ok, before we delve into Java6 we need a Java SDK. The SDK contains everything we need to compile and run our Java programs. Even though we are using Java6 I suggest downloading the latest version of the SDK for use in these lessons. The latest version at the time of writing was Java SE 7u25. The download page can be found at this link Oracle SDK Download. The SDK includes the Java Runtime Environment (JRE) which you must have on your system to run Java applications. The JRE includes the JVM and some other library files and as such creates a JVM to run our Java applications at runtime.
The download comes in Windows, Mac, Solaris and Linux flavours, so after accepting the license agreement, just download the appropriate SDK for your system. When you install the download you get the option of choosing where to put the SDK on your hard drive. I am just using the default directory provided by Oracle, which in my case on my Windows 7 system is C:\Program Files\Java\jdk1.7.0_25\. Where you put the SDK is up to you but remember the path for a bit later in this lesson. I put the JRE in the default directory as well when prompted which in my case was C:\Program Files\Java\. You can register with Oracle after the download has completed for product updates etc.
Setting A Classpath For The Java Compiler
Now we have the SDK installed we need to add a classpath entry to the Path environment variable for where the Java compiler command (javac) resides. First lets open a command line prompt and type in javac. Below is a screenshot of what happens when we do this on my Windows7 system.
The javac command lies within the bin directory of the filepath where the SDK was installed which in my case is C:\Program Files\Java\jdk1.7.0_25\bin\ and so we need to add this classpath to our environment variables. Below is a screenshot of how this is achieved on my Windows7 system and of course other OS will vary. But for Windows From Control Panel, select System >> Advanced System Settings and at the bottom of the window select Environment Variables. Edit the system variable "Path" and add C:\Program Files\Java\jdk1.7.0_25\bin\ (or whatever you selected as your filepath to the SDK) to the end seperating this classpath from the last with a semi-colon.
Once you have done this press OK on the windows to close them all and reopen the command line prompt and type in javac. Below is a screenshot of what happens when we do this on my Windows7 system after adding the classpath. As you can see the javac command now brings up a list of options showing it is now on our classpath and can be used to compile our Java programs.
Are We Going To Use An Integrated Development Environment? (IDE)
You could use an IDE such as Eclipse or Netbeans for developing and compiling your programs in these lessons, but doing so will automate some of the processes that we need to learn to get a real grip of Java. So my suggestion is to use a command-line editor for now so we can see all the processes involved without them being abstracted away beneath the bonnet of an IDE.
Choosing A Text Editor
As we are not using an IDE, we need a simple text editor such as Notepad or Wordpad to write our code. For these lessons we will be using Notepad but the choice is dependant on your preference and OS of course.
Java comes with collections of classes which are held in namespaces known as packages. We can use these packages in our programs by using the
import keyword followed by the namespace.
We will talk about packages and how we import them in the Packages lesson of the API Contents section.
For now and the next few sections of the site we will only be concerned with the
java.lang package which is implicitly imported into all our Java programs for us.
Java comes with very rich documentation that you will go back to time and again. The following link will take you to the online version of documentation for the Java™ Platform, Standard Edition 6 API Specification . I suggest adding this link to your browser's favourites toolbar for fast access.
Lesson 1 Complete
In this lesson we looked at the evolution of Java6 and setting up our environment to begin coding.
Now we have the basic environment set up we can take a look at Java code structure and syntax. In the next lesson we will do just that and run our very first simple Java program.