Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can `apt-get install` be used for JDK?

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

like image 394
Eric Wilson Avatar asked Aug 04 '09 19:08

Eric Wilson


2 Answers

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
like image 163
mmx Avatar answered Sep 20 '22 18:09

mmx


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.

like image 43
kristianp Avatar answered Sep 24 '22 18:09

kristianp