0

Installing Java 6 (1.6) in Linux

Linux

After experimenting with some other distros the past few weeks, I have come full circle and landed back on Ubuntu.... well... Kubuntu this time. After installing Edgy (6.10) I did the update-manager -c -d to upgrade to 7.04 (named Feisty Fawn). So far, I am really enjoying it. For an operating system that isn't even released yet and for a kernel that is less than a week old (kernel 2.6.20.10), it has been rock solid in my first day of really banging on it. One of the biggest adjustments for me is finding my way around KDE tools, but that is relatively minor.

One of the first things I had to do was set up my Eclipse environment. I figured this would be a good time to experiment with Java 1.6 (code name Mustang). From the reviews I have read, it is quite stable and is notably faster than 1.5 in many areas.

I had to jar my memory on the steps to set up a new JRE, so I decided this would make a good blog post in case others need to do the same.

First go to the Sun java download page and pull down the .bin file.

Once the .bin file ( jdk-6-linux-i586.bin in my case) is downloaded, you will need to make it executable. To do this run:

> sudo chmod +x jdk-6-linux-i586.bin

When this is done you can run the .bin file which extracts into a folder named jdk1.6.0 like this:

> ./jdk-6-linux-i586.bin

Now you will want to move that folder into a place with your other Java versions. On Ubuntu/Kubuntu/Xubuntu and probably others, this is in /usr/lib/jvm

> sudo cp -R jdk1.6.0 /usr/lib/jvm/

Historically, from this point I have usually made a symbolic link from /usr/bin/java to jre/bin/java and called it quits. Today I learned a cooler approach using the update-alternatives command. Before we do this next step, take a look at the output of this command:

> sudo update-alternatives --config java

As you can see, your new Java version is not in the list of possible alternatives (or at least it shoudn't be!). We are now going to "install" it so you can then choose it as an option and it will become the version used across your system. To do so run the following:

> sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0/jre/bin/java 300

This has accomplished a few things. We have created the symbolic link to our new java binary. We have then added this version of Java to the update-alternatives and have given it a priority level of 300.

Now go and run this again:

> sudo update-alternatives --config java

You should now see your new version and be able to select it by entering the appropriate number. To confirm that your system is now using Java 6, run the following:

> java -version

If all has gone well, you should hopefully see something like this:

java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode)

Now... off to config the rest of my system!

tags:
Linux
 
worked like a charm!
 
posted 877 days ago
Add Comment Reply to: this comment OR this thread
 
thirstygerry said:
 
It sure did!
Thanks dude
 
posted 861 days ago
Add Comment Reply to: this comment OR this thread
 
Eclipse doesn't like this said:
 
I tried this with a newly installed Eclipse. It failed to run because it couldn't find a JRE. I then added the the command line arg '-vm /etc/alternatives/java' and it ALMOST loaded, but croaked 90% of the way there.
 
posted 857 days ago
Add Comment Reply to: this comment OR this thread
 
 
      For what it is worth, my Eclipse (3.2) doesn't have any issue even without including the -vm switch. What version of Eclipse are you seeing that on?       
 
posted 857 days ago
Add Comment Reply to: this comment OR this thread
 
hobie said:
 
It's 3.2 freshly installed from repository using Adept (I'm Kubuntu as well). It came without a JDK.
 
posted 857 days ago
Add Comment Reply to: this comment OR this thread
 
 
I wonder if that is the difference, I am using a download from eclipse.org. I wouldn't expect there to be any difference, but who knows.
 
posted 857 days ago
Add Comment Reply to: this comment OR this thread
 
 
I can attest that it works with Eclipse 3.2, Eclipse 3.2.2, and Eclipse 3.3M4.

I would check your log file for Eclipse, to see what is happening.

/workspace/.metadata/.log
 
posted 857 days ago
Add Comment Reply to: this comment OR this thread
 
Setya said:
 
Dave,

I'm newbie in Linux, so please excuse me.

Here's my question:

1. After you install Java 1.6.0, where is the original location of folder jdk1.6.0 ? And why do you have to move it to /usr/lib/jvm/ ?
2. You said that historically you usually have created link from /usr/bin/java to jre/bin/java, why is that so ?

Thanks & Regards,

Setya
 
posted 856 days ago
Add Comment Reply to: this comment OR this thread
 
 
Setya, here are my thoughts on your questions:

1) You really don't *have* to move it, but I like to keep things compartmentalized. I have several different versions of the JRE, and I just keep them all under /usr/lib/jvm so I always know where to go.

2) The reason for the symbolic link is so that I can type: $> java [whatever app] and it will use the appropriate JRE. In doing that update-alternatives step, it actually creates that link under the covers.

Hope that helps...

~d
 
posted 855 days ago
Add Comment Reply to: this comment OR this thread
 
Ryan said:
 
Hi Dave,
I'm also a newbie and would like to know if the original folder jdk1.6.0 can be removed since it has been copied to the /usr/lib/jvm folder?
 
posted 841 days ago
Add Comment Reply to: this comment OR this thread
 
 
Sure you can remove it. I have been randomly installing distros lately and keep my /home mount in tact. For that reason I usually keep it just to save re-downloading it everytime. It serves no functional purpose though.
 
posted 840 days ago
Add Comment Reply to: this comment OR this thread
 
Daniel said:
 
hi, I just got linux.

If I type in 'java' in the terminal on any other user besides root, I get bash: java: command not found

Thanx,
Dan
 
posted 837 days ago
Add Comment Reply to: this comment OR this thread
 
 
Out of the box there is no Java installed on some distros. Just follow the steps above and when you do the update-alternatives step, the symbolic link will be created between /usr/bin/java and the Java version you are using. After that point you will be able to run "java" from the terminal. Keep in mind that this is specific to Ubuntu (maybe others, but I am not aware). Typically you would just create that symbolic link by hand rather than using update-alternatives.
 
posted 837 days ago
Add Comment Reply to: this comment OR this thread
 
Daniel said:
 
I have done everything you said but I can only use java if I log in as root. Is there some sort of administrative thing about java that prohibits its use by other users, or am I doing something wrong?

Dan
 
posted 837 days ago
Add Comment Reply to: this comment OR this thread
 
Erich said:
 
It's strange, I execute the update-alternatives command as listed above - and it doesn't produce errors - the list *still* doesn't contain the new jdk... Any ideas?

Thanks in advance!
 
posted 826 days ago
Add Comment Reply to: this comment OR this thread
 
grant said:
 
I am trying to install jre1.6.0_01 on Xubuntu. I have used your instructions slightly modified for jre rather than jdk. All went well, judging from the system responses (it unpacked, etc.), but when I enter:

sudo update-alternatives --config java

the system responds

There is only 1 program which provides java
(/usr/lib/jvm/jre1.6.0_01/bin/java). Nothing to configure.

and when I try

sudo java --version

the system responds

sudo: java: command not found

So, how do I get the system to recognize java.

Another brand new person, btw.

Thanks.
 
posted 825 days ago
Add Comment Reply to: this comment OR this thread
 
Michael said:
 
Thank you, David. Let's see if this helps with Frostwire in Edgy. Excellent how-to! Cheers, Mike.
 
posted 820 days ago
Add Comment Reply to: this comment OR this thread
 
Jonathan said:
 
Hey, David.

FYI - Feisty Fawn is 7.04, not 7.10 ;)
 
posted 808 days ago
Add Comment Reply to: this comment OR this thread
 
 
Wow that has sat there like that for more than 2 months and no one pointed it out until now. Shame on you techie readers! Editing now.... thx Jonathan.
 
posted 808 days ago
Add Comment Reply to: this comment OR this thread
 
Brandon Harper said:
 
I just enabled all of the backport repositories and installed sun-java6-sdk via apt-get. Maybe that wasn't available at the time of writing, but seems like a much better / easier way to install Java 6.
 
posted 808 days ago
Add Comment Reply to: this comment OR this thread
 
 
Good info Brandon. I don't think it was available at the time I wrote this but I wouldn't swear by that. It should be noted that these instructions fit distros other than Ubuntu as well. I followed them to the letter on openSUSE 10.2, which I am running (this week!) and it worked just as it did for Feisty.
 
posted 808 days ago
Add Comment Reply to: this comment OR this thread
 
dave s said:
 
maybe I'm missing something. when I go to download jdk-6-linux-i586.bin a box comes up with choices open with ((make a selection) I don't like any of these) or save to disk which is th only way it downloads.
After sudo chmod +x jdk-6-linux-i586.bin i get cannot access jdk-6-linux-i586.bin :no such file exists. There seems to be a step I'm missing.
 
posted 800 days ago
Add Comment Reply to: this comment OR this thread
 
 
Dave, make sure that you are in the same directory as the downloaded file when you run the chmod. When you do an ls, do you see it there?
 
posted 800 days ago
Add Comment Reply to: this comment OR this thread
 
dave s said:
 
Java was sucessfully install in the following manner.enable all repositories. Go to add/remove software under applications menu. find and select both available java applets and follow onscreen instructions
 
posted 800 days ago
Add Comment Reply to: this comment OR this thread
 
dave s said:
 
still having trouble installing. I've only tried to do this in a user account called msiu. its supposed to have full permission. I can't download to Desktop eithe. whenever I go to download for a source a box that says open with comes up with two options, one being to disk. I need a way to fetch from one location and install or sent to another. I have programmed before in base and fiddled with other languages and used command line before but that was 1991
 
posted 797 days ago
Add Comment Reply to: this comment OR this thread
 
Tim said:
 
Rock on. This is exactly what I was looking for! I didn't know there was such an easy way to add the "latest" version of Java to the update-alternatives setup.
 
posted 722 days ago
Add Comment Reply to: this comment OR this thread
 
Nicolas said:
 
Clear & easy & effective: thank you very much!
following you instruction on openSuse10.2, I simply broke the line
> sudo update-alternatives --install /usr/bin/java java ...
in 2 lines (I start with Linux):
> su
> update-alternatives --install /usr/bin/java java ...

Thanks again to you & all those sharing their knowledge!
Nicolas.
 
posted 652 days ago
Add Comment Reply to: this comment OR this thread
 
Michael said:
 
Hi. I'm using ubuntu gutsy and trying to run frostwire which needs java 6.

michael@michael-desktop:~$ sudo update-alternatives --config java

There are 4 alternatives which provide `java'.

Selection Alternative
-----------------------------------------------
1 /usr/bin/gij-4.2
2 /usr/bin/gij-4.1
*+ 3 /usr/lib/jvm/java-6-sun/jre/bin/java
4 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java

Press enter to keep the default[*], or type selection number:

So I enter '3'

michael@michael-desktop:~$ sudo update-alternatives --config java

There are 4 alternatives which provide `java'.

Selection Alternative
-----------------------------------------------
1 /usr/bin/gij-4.2
2 /usr/bin/gij-4.1
*+ 3 /usr/lib/jvm/java-6-sun/jre/bin/java
4 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java

Press enter to keep the default[*], or type selection number: 3
Using `/usr/lib/jvm/java-6-sun/jre/bin/java' to provide `java'.

But Frostwire will not start....

Any hints?

Thank you.

Michael.

 
posted 581 days ago
Add Comment Reply to: this comment OR this thread
 
Michael said:
 
Hi. No worries now. I uninstalled the 'old' Frostwire and downloaded the newest version. All fine.
Cheers.
Mike.
 
posted 581 days ago
Add Comment Reply to: this comment OR this thread
 
joao ferreira said:
 
Hi. I'm running kubuntu 7.04 and the steps you mentioned worked just fine. Thanks!
 
posted 580 days ago
Add Comment Reply to: this comment OR this thread
 
Inga said:
 
Thank you for the instructions, Dave. Something isn't working for me tho'. Hope you can help.
I installed jre1.6.0_03, moved it to /usr/lib/jvm/. After I type
> sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.6.0_03/jre/bin/java 300

and then
> sudo update-alternatives --config java

I still do not get new Java version in the list of possible alternatives.
What am I doing wrong? Thank you,
- Inga
 
posted 561 days ago
Add Comment Reply to: this comment OR this thread
 
 
Hmmm... you will notice in my instructions that I am using the JDK rather than the JRE. I am inclined to believe that is the difference. Check out the first download on this page:
http://java.sun.com/javase/downloads/index.jsp
 
posted 561 days ago
Add Comment Reply to: this comment OR this thread
 
Inga said:
 
Thanks for straightening me out, Dave, all works now,
- Inga
 
posted 560 days ago
View Replies (1) || Add Comment Reply to: this comment OR this thread
 
.: HIDE REPLIES :.
Scott said:
 
I'm pretty new to Linux (just installed Gutsy). I followed all of your directions, and got the correct output, but when I try to open an applet with firefox it says I'm missing the JRE plugin. Is there something else I have to do? Thanks.
 
posted 533 days ago
Add Comment Reply to: this comment OR this thread
 
 
OH Man! How timely your question is Scott...

I had to do a Webex presentation on Mach-II yesterday to a group on the other side of the country. Webex requires the JRE plugin which I have never actually had working. Keep in mind that JRE != JDK. The instructions above are for installing the JDK, not the JRE plugin.

So... I am running Gutsy as well and actually use Swiftfox as my browser. I followed all the instructions I could find. I even changed my java from the instructions above to the ubuntu package sun-java6-bin. Finally after ripping out Firefox and reinstalling it and ripping out Swiftfox, I ran:

sudo apt-get --purge remove sun-java6-bin sun-java6-jre sun-java6-plugin

I wanted to make sure I was doing those from scratch. I then ran:

sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-plugin

I went back to my browser and typed in about:plugins in the address bar and still showed no Java plugin. I then went into ~/.mozilla/plugins and did the following:

sudo rm libjavaplugin*

This removed a java plugin that was in there that was obviously not working. I then did a symlink like this:

ln -s /etc/alternatives/firefox-javaplugin.so ./libjavaplugin.so

I then restarted my browser and hit about:plugins and BAM! I tested my applet and all is well.

Hope this helps...
 
posted 532 days ago
View Replies (3) || Add Comment Reply to: this comment OR this thread
 
.: HIDE REPLIES :.
Scott said:
 
I tried the command

sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-plugin

and I got the following message:

The following packages have unmet dependencies:
sun-java6-bin: Depends: unixodbc but it is not installable
Depends: libstdc 5 but it is not installable
sun-java6-jre: Depends: java-common (>= 0.24) but it is not installable
E: Broken packages

I also tried Linux Manual Installation directions on java.com. The JRE installed and I made the symbolic link, but that didn't work either.
 
posted 532 days ago
Add Comment Reply to: this comment OR this thread
 
Scott said:
 
Hmm, it turned out that I somehow had two different firefox directories. I made a symbolic link in the other (apparently correct) plugins folder and it worked. Thank you for your help though!
 
posted 532 days ago
Add Comment Reply to: this comment OR this thread
 
 
That is actually very similar to what I experienced. At first I had linked into the /usr/lib/mozilla/plugins directory which failed.
 
posted 532 days ago
Add Comment Reply to: this comment OR this thread
 
Setya said:
 
Hi Dave,

I've tried your commands on Xubuntu 8.10. But it seems Xubuntu ignores the link and instead when I invoke 'java -version' it throws :

The program 'java' can be found in the following packages:
* java-gcj-compat-headless
* cacao-oj6-jre-headless
* gij-4.2
* kaffe
* cacao
* openjdk-6-jre-headless
* jamvm
* gij-4.3
* sablevm
Try: sudo apt-get install
bash: java: command not found


Any idea why ?


Setya
 
posted 212 days ago
Add Comment Reply to: this comment OR this thread
 
Setya said:
 
I've tried your commands on Xubuntu 8.10. But it seems Xubuntu ignores the link and instead when I invoke 'java -version' it throws :

The program 'java' can be found in the following packages:
* java-gcj-compat-headless
* cacao-oj6-jre-headless
* gij-4.2
* kaffe
* cacao
* openjdk-6-jre-headless
* jamvm
* gij-4.3
* sablevm
Try: sudo apt-get install
bash: java: command not found


Any idea why ?


Setya
 
posted 212 days ago
Add Comment Reply to: this comment OR this thread
 
wow gold said:
 
 
posted 69 days ago
Add Comment Reply to: this comment OR this thread
 

Search