• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to install JDK6 on Ubuntu?

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
I got the JDK6 from Java's site and I'm wondering to install it.
I have to create an environment variable too, right?
Thanks.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the easiest way is via Synaptic, install sun-java6-jdk

Otherwise you should follow the instructions on the Sun site, which involves making the binary executable then running it

chmod +x (file)
./(file)
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are probably several ways to do this. Here is how I do it.

Download the Linux .bin file from Sun's site.
chmod +x xxx.bin
./xxx.bin
Accept license.
mv jdk1.6.x_x wherever you want

vim .bashrc
export JAVA_HOME=/where/you/put/the/jdk
export PATH=$JAVA_HOME/bin:$PATH
:qw

Done!

I usually install all the JDK's in a dev folder under my home location. JAVA_HOME typically points to the most recent version for general java applications that run. When doing development I always point my build/IDE to a specific version aside from JAVA_HOME.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The newest version of Java 6 (version 1.6.0 update 3) is in the Ubuntu 7.10 repositories. Installing software from the repositories is the preferred way on Ubuntu.

You can install sun-java6-jdk and sun-java6-plugin (the browser plug-in, to run applets) from Synaptic or by typing in the following command:

sudo apt-get install sun-java6-jdk sun-java6-plugin

Note that Ubuntu by default comes with GNU Java, which is a slow and incomplete (but 100% open source) version of Java 1.4. After installing Sun Java 6, you might need to make it the default Java used on your system with the following command:

sudo update-alternatives --config java

Select Sun Java 6 in the menu that appears.

You do not need to create any environment variables.
[ January 04, 2008: Message edited by: Jesper Young ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jesper Young:

sudo update-alternatives --config java



I didn't know about that. Cool! Thanks Jesper.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gregg Bolinger:


I didn't know about that. Cool! Thanks Jesper.



If you want to have a look under the hood, try:

You can change a symbolic link by hand :-)

I always install various JDKs in /opt. Later, I use different environment variables (or configs inside Eclipse) to point to one JDK or another.
 
Hussein Baghdadi
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all guys.
I used Synaptic as Mr. Jesper suggested and it works.
By using Synaptic to get JDK6, should I create JAVA_HOME environment variable by hand or Synaptic get it done?
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by John Todd:
should I create JAVA_HOME environment variable by hand or Synaptic get it done?

What happens if you type echo $JAVA_HOME ?
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think that by installing it via Synaptic a JAVA_HOME environment variable will be set up. As Jan says, you can check if it is set with echo $JAVA_HOME.

You don't really need a JAVA_HOME or any other environment variable for Java to work. Some programs, like Tomcat, use this variable to determine where the JVM is on Windows (I'm not sure if the Linux version of Tomcat needs this too).
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a little to add to Jesper's detailed post-
To set ALL the java related symlink automatically to the Sun version of Java (e.g. apt, servtool, jar, javap etc.) do this:

sudo update-java-alternatives --set java-6-sun

Also, please DO NOT use the official Sun tarballs to install JDK - that way the JDK is not registered with the package manager and alternatives system, and more often than not the firefox plugin won't work either.

Incidentally, the JAVA_HOME variable is not set by the package manager, because it is assumed that all java software will be installed using the package manager, and that doesn't need JAVA_HOME variable set.
This is not always the case, for example I had to install maven manually, which requires that variable. Hence I have added this line to by ~/.bashrc file:

[ -d /usr/lib/jvm/java-6-sun-1.6.0.03 ] && export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.03

Hope that helps
[ January 07, 2008: Message edited by: Rohan Dhruva ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic