I have a Ubuntu Server.
From the terminal, how should I install JDK?
In this guide it says to use this command:
sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
But on Suns website, it says JDK includes the JRE, so why the JRE in the line above?
Anybody know how to actually install Java?
Every guide and every forum shows different ways of doing it.
BTW: It is a VPS (virtual private server)
Use
apt-get install sun-java6-jre sun-java6-jdk
. Just because Oracle's (Sun's) JDK distribution also contains a JRE does not necessarily mean that the Ubuntu team packaged it the same way.Of course, if you do not want to develop Java applications on your server but only want to run them,
sun-java6-jre
should be enough.Here is how I do it:
I download
jdk-6u20-linux-i586.bin
from sun, unpack it by executingsh jdk-6u20-linux-i586.bin
.Move the resulting directory to ~/bin directory (
/home/username/bin
) and add it your path in.bash_profile
.HTH
Edit:
Well, in a server environment, when I have to use a specific version of jdk (tomcat application as an example) I install jdk as above. Cheers!
From my Trusty book of notes.
Acquiring JRE/JDK
First we need to download JDK and JRE 6 for CentOS. Download the following files to your root directory (~) with 'wget'. Note that you may need to change the file names as they may have some URL variables added to the name. Be sure to not download the RPM files.
Installing
Now that we have the files downloaded we need to create an installation directory for Java.
sudo mkdir /usr/java cd /usr/java
Now we need to execute the installation for Java Development Kit (JDK). In our example we will use specific file names. Keep in mind that your file names may vary.
sudo sh ~/jdk-6u14-ea-bin-b03-linux-amd64-10_mar_2009.bin
Press space to advance through the license agreement and type 'yes' to accept. Press enter to finish the installation.
Now we need to install the Java Runtime Edition (JRE). In our example we will use specific file names. Keep in mind that your file names may vary.
sudo sh ~/jre-6u14-ea-bin-b03-linux-amd64-10_mar_2009.bin
Press space to advance through the license agreement and type 'yes' to accept.
Verify the installation by typing ls. You should see two directories: jdk1.6.0_14 and jre1.6.0_14. Keep in mind that your version numbers may differ slightly.
Installing Ant and Tomcat
Next we will need to download and extract Apache Ant. Ant is an installation utility used by several Apache products.
To download Apache Ant you will need to visit the following website to download the installation file:
http://ant.apache.org/bindownload.cgi
Scroll down the page and find the .tar.gz under Current Release of Ant. Copy the URL and use wget to download the file to the /usr/share directory. Your version number may differ.
cd /usr/share sudo wget http://mirror.olnevhost.net/pub/apache/ant/binaries/apache-ant-1.7.1-bin.tar.gz
Next we need to unpack that file so we can install it. Note that your version number may be different.
sudo tar -xzf apache-ant-1.7.1-bin.tar.gz
I've setup an instant messaging server (using spark IM server software). It requires java so I installed as follows
works fine to me.
Here is a great example of the RIGHT way to do it, which is similar to Paul's answer.
http://wporta.wordpress.com/2010/07/06/installing-jdk-in-fedora-13/