Can `apt-get install` be used for JDK?
Solution 1
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.
Solution 2
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
Solution 3
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.
Solution 4
My Ubuntu box has sun-java5-jdk
and sun-java6-jdk
available.
Solution 5
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.
Eric Wilson
Software developer, experienced in Java and Python in Linux environments, formerly a professor of mathematics. I'm a father of five children, and a husband of one wife.
Updated on June 05, 2022Comments
-
Eric Wilson almost 2 years
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
-
sorin over 11 yearsThat's not true anymore, nor for Oracle JDK 6 or 7.