Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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)

Thanks

share|improve this question

migrated from stackoverflow.com May 29 '10 at 14:12

This question came from our site for professional and enthusiast programmers.

1  
The JDK often comes with a jre subfolder that contains the JRE but this is intended for use by the JDK only and not intended for general use by the rest of the system. For system wide use install the JRE. –  Chris Nava May 30 '10 at 2:33

6 Answers 6

Just for free-software's sake:

sudo apt-get install openjdk-6-jdk
share|improve this answer

Regardless of how Sun's Java packages work on other platforms, for Ubuntu the JDK package does not depend on the JRE package.

Both the JDK and JRE packages depend on the -bin package, but installing -bin this way marks it a non-automatic install.

share|improve this answer

Okey, this is my second answer to this question, and this is how you install a current JDK on linux! (Its for Debian, but Ubuntu users shouldn't see many differences).

Tools you need:

apt-get install fakeroot zip unzip mkisofs

Now go to java.sun.com and download a current JDK6. It should be names something like jdk-6u20-linux-i586.bin!

We don't want to install it directly to make it behave like a good package. So we use fakeroot to install it as someuser.

mv jdk-6u20-linux-i586.bin ~someuser
su - someuser
fakeroot
chmod a+x jdk-6u20-linux-i586.bin
sh ./jdk-6u20-linux-i586.bin
cd jdk1.6.0_20/man
for i in `find -type f`; do gzip $i; done;
cd ../..
# Tar the results to have them handy for the real installation
tar cfz jdk1.6.0_20.tgz jdk1.6.0_20/

Now we leave fakeroot (Ctrl-D) and the someuser-shell (Ctrl-D again), and install our tar to /usr/local:

cd /usr/local
tar xfvz ~someuser/jdk1.6.0_20.tgz
ln -s /usr/local/jdk1.6.0_20/ /usr/local/jdk
ln -s /usr/local/jdk1.6.0_20/jre/ /usr/local/jre

for program in appletviewer apt extcheck idlj jar jarsigner java javac \
           javadoc javah javap javaws jconsole jdb jhat jinfo jmap \
           jps jrunscript jsadebugd jstack jstat jstatd jvisualvm \
           keytool native2ascii orbd pack200 policytool rmic rmid \
           rmiregistry schemagen serialver servertool tnameserv \
           unpack200 wsgen wsimport xjc ; do \
    update-alternatives --install "/usr/bin/$program" "$program" \
    "/usr/local/jdk1.6.0_20/bin/$program" 1130 \
    --slave "/usr/share/man/man1/$program.1.gz" "$program.1.gz" \
    "/usr/local/jdk1.6.0_20/man/man1/$program.1.gz"; done;

Nun testen ob alles ok ist:

java -version
man java

Done.

share|improve this answer

Whilst you are correct that when you normally download a JDK from Sun (e.g. if you were to download the Windows installer) it would include a JRE it is common for things on Debian (and Ubuntu) to be packaged in a more modular way. e.g. the documentation and source (again normally included in a JDK download) are in other separate packages: sun-java6-demo and sun-java6-source.

share|improve this answer

Here is what you get from each package:

sun-java6-bin: Basefiles to execute Java programs

sun-java6-jre: Localization files and everything you need to fulfill the "full" Runtime requirements. Depends on bin.

sun-java6-jdk: Everything you need to compile stuff. This does not nessecarily need the Runtime to execute java programs. Depends on bin.

So you can write your command shorter as:

sudo apt-get install sun-java6-jre sun-java6-jdk
share|improve this answer
    
translation: Since the JRE depends on the -bin, the two commands are functionally equivalent. –  Chris Nava May 30 '10 at 3:44

This is the right way to do it on debian based systems. The reason they're including it is probably to secure the dependencies (even though apt solves them automatically)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.