Tag Archives: JDK

installing-jdk on Ubuntu 12.04

How to install JDK on Ubuntu 12.04

If you are a Java developer or a beginner, who just installed Ubuntu 12.04 LTS (Precise Pangolin) then JDK (Java Development Kit) is the first thing you want to install (although you might consider installing these essential things too).

In the previous version of Ubuntu, sun-jdk was also available – in 12.04 you might install it from an external PPA but it’s not recommended better try open-jdk or oracle-jdk (Oh!, I don’t recommend this either). So this post might help you in setting up Java development environment on Ubuntu 12.04 LTS.

Although, this post explains only about JDK but you may like to setup Eclipse (Most Popular IDE for Java programmers) IDE and Java server environments like Apache Tomcat, JBOSS or whatever depending on your project.

installing-jdk on Ubuntu 12.04

Installing JDK on Ubuntu 12.04 (Precise Pangolin)

In official package, v 6 as well as 7 is available. So if you’re already working on a project then you would obviously go for that, otherwise latest version is recommended. JDK includes default JRE(Java Runtime Environment) according to the version, and other dependencies. If you don’t like command line interface then better go for synaptic package manager (above snapshot).

Install OpenJDK 7

sudo apt-get install openjdk-7-jdk


Install OpenJDK 6

sudo apt-get install openjdk-6-jdk

Update1 : Synaptic Package Manager snapshots added!


Sun JDK will be removed from Ubuntu Partner Archive

In a recent announcement, Canonical has specified that Ubuntu Partner Archive will no longer contain Sun JDK, the packages (sun-java6-jre, sun-java6-jdk, sun-java6-plugin, sun-java6-source etc) will be removed on 16th of the next month, due to some licensing problem, as the said in announcement –

we no longer have permission to redistribute new
Java packages as Oracle has retired the “Operating System Distributor License for Java”

Although, it will be remain installed on the systems but no security updates will be provided in future so the ubuntu users who are dependent on Sun JDK or any of this component are recommend to migrate to OpenJDK or Oracle JDK if you get any problem with open JDK in some applications.


Migrating from Sun JDK to Open JDk

Uninstall Sun JDK and its components

sudo apt-get purge sun-java*

Then install OpenJDK 7/6

sudo-apt-get install openjdk-6*

If you want to install only few selected package such as openjdk-6-jre then type

sudo apt-get install openjdk-6-jre

how to install jdk on Ubuntu 11.10

Java is one of the most popular programming language and its popularity has undergone an exponential growth (probably because it’s well suitable in distributed environment – you can use Java to develop cool web application with a lot of complex features as well as in developing sophisticated desktop applications, and it’s platform independent – ‘write once and run everywhere‘) in fast few years.

Similarly Ubuntu (latest version : Ubuntu 11.10 beta 1) has become the most popular Linux distro – for desktop environment. That’s why, Ubuntu is now considered as a great platform for developing Java applications.

Anyway, if you are an Ubuntu user and going to start learning Java or a java programmer/developer – want to start coding on Ubuntu, this post is about installing Java Development Kit (JDK) on Ubuntu 11.10 (although it is expected to work on other Debian based Linux distro too). On the other hand if you’re an Ubuntu user, interested only in running java applications then you don’t need to install jdk (it has lot of components which is not required for executing a java program/software) – instead you just need to install jre on Ubuntu 11.10 i.e java runtime environment (includes Java Virtual Machine, for executing java bytecode/class).

Java - jdk for Ubuntu 11.10

Installing Java Development Kit (JDK) on Ubuntu

There’re many JDK available thesedays. One of the most popular – open source jdk is openjdk. OpenJDK is well compatible with Ubuntu/Linux and it is available in official repository – so you can install it a click.

install openjdk on Ubuntu 11.10

Open a terminal (Ctrl+Alt+t) and execute the command(s) –

sudo apt-get install openjdk-7-jdk

OR you can install sunjdk

Update1 : The sun jdk isn’t included with the official repository, so you first need to add a PPA for that; Thanks to Casier :).

sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugin

That’s All..have fun in programming in Java, with Ubuntu!


how to install jdk on Ubuntu 11.04

Ubuntu (Latest Stable Version : Ubuntu 11.04 (Natty Narwhal) ) is one of the most popular Linux distribution on this planet while Java, the most popular programming language (Platform independent features makes Java Great! and superior to any other programming language, for building web and Desktop Applications). Due to a number of free( and of course they’re good) tools, compilers and other options Ubuntu has become the No. 1 choice, as a development platform, among the Java Developers (specifically young programmers).

If you are just a common user then you need only JRE (Java Runtime Environment) to execute java programs but If are going to write java programs or develop Apps then you need to install Java Development Kit (JDK, complete suite for Java Developers) along with some IDE like Eclipse or Netbeans (Not really necessary for absolute beginners). A lot of JDK’s are available, so if you have programmed before then choose the one you like, but on the other hand, try open-jdk-6, an open source Java Development Kit (contains Javac, an open source Java compiler and ). This post will explain – about installation procedure of Open-JDK on a freshly installed Ubuntu 11.04.

Java logo

Installing Java Development Kit (JDK) on Ubuntu 11.04

#1 : Open Synaptic Package Manager (and click on update button, it’s not necessary but it’s usually a good practice because in this way you will get the latest details about the packages), and search for ‘JDK’ or ‘open jdk’ in the quick search bar.


#2 : Then select the package for installation ( by checking the small square box) and click on ok, if it asks for dependencies.

#3 : Now, click on ‘Apply’ button to begin the installation procedure…and wait for the installation to complete.

#4 : That’s All..to verify, open Terminal (CTRL+ALT+T) and type javac, you will see a lot info about the Java Compiler and …

Install JDK from command Line

Open Terminal and enter the following command(s), then enter your ubuntu login password followed by ‘y’ when prompted for yes/no.

sudo apt-get install openjdk-6-jdk
how to program in java on ubuntu 10.04

Java Programming on Ubuntu 10.04

Java is multi platform programming language.It uses JDK(includes jre) to create a class file from the source code and then the generated class file can be run on any computer by using Java Virtual Machine(JVM).So to write and execute java programs Java Development Kit(JDK) must be installed on the computer.

Installing JRE /JDK on Ubuntu 10.04 for java programming
If you have not installed the JDK yet, then first install jdk on ubuntu 10.04 and then return to this page.
When you have installed JDK successfully on ubuntu ,then you will be able to write and execute jav programs.Follow these simple steps to write and execute your first java program on ubuntu 10.04 –

How to compile and run java program on Ubuntu 10.04

1. Open Gedit OR Write click on Desktop and select Create Documents->Empty File.

2. Write this simple java code to test..

// A program to print some text.
public class Welcome
// main method begins execution of Java application
public static void main( String[] args )
System.out.println("Hello World!");
System.out.println("Welcome to Java Programming! on Ubuntu 10.04");

} // method main ends here
} // end of the class Welcome

3. Save it as “Welcome.java” on your Desktop(or in any other directory).
4. Now compile this java program to create the class file by using this command on terminal(CTRL+ALT+T).

$ javac Welcome.java

5. Now you will notice a class file “Welcome.class” on your Desktop.Now JVM will execute this code through the command given below –

$ java Welcome

6. Then the java Program will be execute by jvm and you will see the following output.
Hello World!
Welcome to Java Programming! on Ubuntu 10.04

how to program in java on ubuntu 10.04