Question

I've been using a linux machine for less than two weeks, so I am extremely new to Linux.

I'd also like to install the Java Developers Kit. How should this be done? Is there an apt-get command, or should I just click on the download button at Sun's website?

I'm sure there is more than one way to do this, and it probably doesn't matter much, but I was impressed with how smoothly apt-get install worked when installing PHP and MySQL, so if there is a right way to do this, I'd like to know.

I'm using Ubuntu version 9.04

Was it helpful?

Solution

The Oracle JDK is no longer included in the Ubuntu repos. According to https://stackoverflow.com/a/15543636/192221 , the following ppa can be used:

echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java7-installer

If you have OpenJDK installed already, you might need to use

update-alternatives --config java

to use the Oracle Java by default.

OTHER TIPS

Yes, definitely it's the suggested way to install JDK on your Linux system (if available).

On Ubuntu:

sudo apt-get install sun-java6-jdk

If you for some reason need to install the sun packages you can use the make-jpkg command to create a deb file and still have the files managed by apt/dpkg.

To do this:

sudo apt-get install java-package
fakeroot make-jpkg jre-1_5_0_06-linux-i586.bin

you will then have a .dpg file that you can install using for example gdebi

gdebi-gtk jre.deb

Also note that you can have multiple JDKs installed and switch between them using update-alternatives:

update-alternatives --config java
update-alternatives --config javac

and so on for other java related binaries, have a look in /etc/alternatives to find out which are available.

In Ubuntu 9.10 Karmic Koala apt-get and the Synaptic Software Manager both install version 6.15.1 of Sun Java and the JDK, which are now out of date, and an old version of Netbeans,, so don't use "sudo apt-get install" for these.

Go to the Sun Java download page http://www.java.com/en/download/manual.jsp

Select the non-RPM 32-bit or 64-bit self extracting file, download it and check the file size of the downloaded file. Doesn't matter where you download it.

Click on the link to installation instructions for the corresponding file.

An easier way to set executable permission is to right click on the file in the file browser (Nautilus) and click Properties, then on the Permissions tab, click the Execute checkbox.

To test, open a new terminal and type:

java -version

You should see Java version "1.6.0_18" etc.

If you don't, you probably need to add some lines, adjusted to suit your installation directories, to .bashrc and .bash_profile which are both hidden files in your home directory.

gedit .bashrc

Add the following:

export JAVA_HOME=/opt/java/64/jre1.6.0_18
export PATH=$PATH:$JAVA_HOME/bin

Then edit your .bash_profile file and insert the same lines at the end:

gedit .bash_profile

Open a new terminal window and test as above.

If all went well, in the Applications menu > System Tools, you should now have the Sun Java Control Panel.

You can repeat a similar installation procedure for the JDK and Netbeans where you mark the downloaded .bin file as executable and then execute it from a terminal window in the directory you want to install into, such as /usr/local.

After installing the JDK, add to your .bashrc and .bash_profile files a line similar to this:

export PATH=$PATH:/usr/local/jdk1.6.0_18/bin

Netbeans 6.8 seems to be able to set itself up ok without any editing and adds itself to the Applications Programming menu.

My Ubuntu box has sun-java5-jdk and sun-java6-jdk available.

I am personally a linux mint person. However, I couldn't find this in my respitory:

sudo apt-get install sun-java6-jdk

After poking around for a bit, I was able to get this to work.

sudo apt-get install openjdk-6-jdk

Cheers.

I'm not sure Ubuntu 9.04. Is it openJDK? But in Ubuntu 9.10 It is openJDK. So It have many problem.

You can do like this to remove and install sun java jdk

sudo apt-get remove openJDK* sudo apt-get install sun-java6*

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top