Installing Java in Linux/UBUNTU

Java is an object-oriented programming language developed by Sun Microsystems in the early 1990s. Java applications are compiled to bytecode, which at runtime is either interpreted or compiled to native machine code for execution.

The language itself derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. JavaScript, a scripting language, shares a similar name and has similar syntax, but is not directly related to Java.
To run Java programs, or scripts, in Ubuntu and other Linux distributions, you must first have a Java runtime environment installed. There are open-source Java packages available, but since the Sun Java package is available from the “Universe” repository, it is best to install that package. The Sun Java package is the package created directly from the Sun Microsystems binaries. Once the Java packages are installed and set up correctly, the script can be run from the command line.

Currently Ubuntu has the following Java packages

sun-java6-bin – Contains the binaries

sun-java6-demo – Contains demos and examples

sun-java6-doc – Contains the documentation

sun-java6-fonts – Contains the Lucida TrueType fonts from the JRE

sun-java6-jdk – Contains the metapackage for the JDK

sun-java6-jre – Contains the metapackage for the JRE

sun-java6-plugin – Contains the plug-in for Mozilla-based browsers

sun-java6-source – Contains source files for the JDK

Installing the Java Runtime Environment


Step 1 Open a terminal window. This is where you will type the following commands.

Step 2 Type the command “sudo apt-get install sun-java6-bin, sun-java6-jre” to install the proper Java packages.

Step 3 Type the command “sudo update-java-alternatives –set java-6-sun” to correctly set the correct packages as default.

Step 4 Type the command “cd ” to navigate to the directory where the Java script is held. Replace “” with the correct path for your system.

Step 5 Type the command “java ” to execute the program. Replace “” with the correct name of the script you want to run.

Testing Java Runtime Environment

You’ll want to confirm that your system is configured properly for Sun’s JRE. This is a two-step process.

First, check that the JRE is properly installed by running the following command from a terminal.

java -version

You should get similar output

java version “1.6.0″
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: