I know this is very basic question, but these days I have done all my Java programs on Windows OS. But now I like to go with Linux. How JDK and all be installed in Linux OS?

I am using Ubuntu 10.04 LTS.

+4  A: 

That is dependent on the distribution you are using -- provide more details so people can be more helpful.

In most distributions however this is as simple as installing a package from the official repositories.

For example, in Debian/Ubuntu etc. you can do:

sudo apt-get install sun-java6-jdk

which will get you both the JDK and the JRE which is a dependency.

@giri this answer is correct, but please specify which distro you're using because that command won't work on all distros.
or, if you're using a recent ubuntu version, just open up the software center, search for java and install that. It's easier for "newcomers" this way ;)
The jre is a dependency of the jdk, so the second argument is redundant.
Dirk Eddelbuettel
@Dirk Eddelbuettel: thanks, I wasn't sure (I don't use Ubuntu so I couldn't test). Removed it.
+2  A: 

On Ubuntu:

$ sudo apt-get install openjdk-6-jdk openjdk-6-demo openjdk-6-doc

gets you the SDK, its demos and documentation. You should then be able to run the first set of examples.

Dirk Eddelbuettel

What distro of linux do you've ? In Mint/Ubuntu, you could use the package manager. Just open it and search for sun-java6-jdk (or whatever version you need).

PS: maybe this should be a community wiki?


It depends on your distribution. In Ubuntu you would do something like this (as root)...

# aptitude search jdk

After your choice, you install it.

# aptitude install sun-java6-jdk

Don't bother about downloading anything from any website. The package manager (apt-get, aptitude) is doing that for you.


Many Linux distributions package the OpenJDK into their repositories so you can install Java like any other application. If you want the Sun version of Java then you can download a bin or rpm file directly from Sun/Oracle that you can install manually.

The Sun/Oracle version can be found here: http://java.sun.com/javase/downloads/widget/jdk6.jsp Just select Linux as your platform in the form.


In addition to others' answers: If you need Java packages beyond what your distro provides, then check out the JPackage project. JPackage provides RPMs (so it won't work on Debian or Ubuntu, unless you use Alien) of a large number of Java libraries, frameworks, and tools.

Josh Kelley

As people have noted, you can use apt-get to install the JDK:

sudo apt-get install sun-java6-jdk

Also, if you're looking for a graphical editor, Eclipse is a good one, especially when you're not very familiar with Unix operating systems. It also should come with the JDK included with the default install. You can download that with:

sudo apt-get install eclipse

As Tedil mentioned, you can also get this without the console work via Ubuntu's Software Center in the Applications menu from the top bar.

Sean O'Hollaren