Installing Java

In this part of the JEE tutorial series, we will install the Java Development Kit (JDK). The JDK is a software development kit used to create Java applications. If we need to run Java applications, we only need the Java Runtime Environment (JRE). If we want to create Java applications, we also need the JDK. The JDK also includes JRE. Primary components of the Java Development Kit are Java compiler, launcher, documentation generator, debugger, disassembler, archiver.

There are three basic Java editions.

If we download the JDK we can create Java SE applications. These are basically command line applications a Java Swing GUI applications. Java EE is used to create enterprise applications. The Java ME is used to create mobile applications. For both of them, we need to install additional libraries. Java EE is the target of our tutorials.


These are the steps to install the latest JDK on Linux. When I write these words it is JDK 6 Update 3.

  1. go to http://java.sun.com/
  2. select menu downloads - Java SE
  3. click on the download button of the latest JDK version
  4. accept licence agreement
  5. download the the appropriate version of java, Linux self-extracting file, 65.40 MB
  6. sudo chmod +x jdk-6u3-linux-i586.bin
  7. ./jdk-6u3-linux-i586.bin
  8. Do you agree to the above license terms? [yes or no] yes
  9. mv jdk1.6.0_03/ installdir
$ export PATH=$PATH:/home/vronskij/bin/jdk1.6.0_03/bin/

We add the bin directory to the PATH variable. On my computer the path to the Java bin directory is /home/vronskij/bin/jdk1.6.0_03/bin/.

$ java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)

We verify the installed version of java. Now let's create a simple Java console application. Launch your favourite text editor and write down the following code.

/* Console.java */

public class Console {

    public static void main(String[] args) {
        System.out.println("Java console application");

This sample program will print text on the console window.

$ javac Console.java
$ ls
Console.class  Console.java  Console.java~
$ java Console
Java console application

We compile the source code with the javac command. Then we launch the program with the java command.

export JAVA_HOME=/home/vronskij/bin/jdk1.6.0_03/bin/

We set up the JAVA_HOME variable to point to our JDK. This is for other applications like ant or Netbeans, so that they know, where the Java has been installed.

In this part of the JEE tutorial, we covered Java installation.