Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I followed all the instructions stated at this question, but am encountering some problems with the last part of it.

I actually have version 6.22 of java and would like to update to version 6.30.

So after moving the extracted directory java-6-oracle into /usr/lib/jvm I do not know what to do, since the script that is pointed out in the answer above updates from java 5 to java 6.

For sake of clearness here is output if I do an ls in dir /usr/lib/jvm:

matteo@matteo-ThinkPad-SL:/usr/lib/jvm$ ls -l

total 8

lrwxrwxrwx 1 root root 14 2011-07-12 15:18 default-java -> java-6-openjdk

lrwxrwxrwx 1 root root 14 2011-07-12 12:19 java-1.6.0-openjdk -> java-6-openjdk

drwxr-xr-x 10 root root 4096 2012-04-12 12:06 java-6.31-oracle

drwxr-xr-x 7 root root 4096 2012-02-24 14:43 java-6-openjdk

What should I do now?


ADDED PART

Under the suggestion of @fossfreedom I ran the script anyway and actually it updated the java version.

Infact if I run command java -version outpu will be the following:

matteo@matteo-ThinkPad-SL:~$ java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) Server VM (build 20.6-b01, mixed mode)

There is still a problem, if Irun javac -version it gives me the old version installed:

matteo@matteo-ThinkPad-SL:~$ javac -version
javac 1.6.0_22

And if I use the tester at this link it will tell me that version is

Java Version 1.6.0_22 from Sun Microsystems Inc.

What's going wrong?

It seems that Java Runtime Environment has updated, but Java Compiler and Java plugin for browser have not.

How can I update them?


OTHER ADDED PART

sudo update-alternatives --config java will return following output

matteo@matteo-ThinkPad-SL:~$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                      Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6.31-oracle/bin/java     1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-6.31-oracle/bin/java     1062      manual mode

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

these makes sense with the fact that JRE is correctly updated to version 6.31, issues are on Java Compiler and Java browser plugin.

Any ideas?

share|improve this question
    
... are you talking about the webupd8 script? What do you see when you run the script? – fossfreedom Apr 13 '12 at 11:08
    
@fossfreedom I haven't tried it cause I thought it wasn't a good idea being it explicitely written for uploading from Java 5 to 6, should I anyway? – Matteo Apr 13 '12 at 12:01
1  
hmmm - possibly you may be confusing that the webupd8 script is 0.5b? That is the version of the script - it doesnt refer to the java version. Give it a try. Lets see a screenshot of what the window looks like when you run the script. – fossfreedom Apr 13 '12 at 12:13
    
@fossfreedom yeah that totally confused me ;D I ran the script! check the edits in question!thks a lot for helping me.. – Matteo Apr 13 '12 at 12:16
    
how very strange ... never encountered that. Anyway - look at the answer just below - you should be able to sudo update-alternatives as per the example. – fossfreedom Apr 13 '12 at 12:20
up vote 53 down vote accepted

Re your first question:

possibly you may be confusing that the webupd8 script is 0.5b. That is the version of the script - it doesnt refer to the java version.

Further to the setting of the javac version.

I suspect you need to explicitly give the path of the javac compiler

i.e.

sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-6.31-oracle/bin/javac" 1

followed by:

sudo update-alternatives --config javac

With regards to setting up the java chrome plugin.

The master question:

How do I install Oracle's JDK 6?

includes this information - since your folder structure is slightly different your link command should be:

ln -s /usr/lib/jvm/java-6.31-oracle/jre/lib/i386/libnpjp2.so ~/.mozilla/plugins/
share|improve this answer
    
On its own this just changes the compiler - see the answer below for update-java-alternatives which handles switching all of the java-related alternatives, which is 82 on my system. – Greg May 10 '14 at 10:16

I think you should take a look at the update-java-alternatives command from the java-common package and the *.jinfo files used by it. With that you should be able to switch completely between java installations (regardless of JDK, JRE, ...).

share|improve this answer
    
I tried the update-java-alternatives and then java -version was correct, but the link in $JAVA_HOME was still wrong... I changed that one manually, but I wonder whether there is something missing in the update-java-alternatives in that regard. – Alexis Wilke Apr 16 at 5:09

See this; run

sudo  update-java-alternatives --list

to list off all the Java installations on a machine by name and directory, and then run

sudo  update-java-alternatives --set [JDK/JRE name e.g. java-8-oracle]

to choose which JRE/JDK to use.

If you want to use different JDKs/JREs for each Java task, you can run update-alternatives to configure one java executable at a time; you can run

sudo  update-alternatives --config java[Tab]

to see the Java commands that can be configured (java, javac, javah, javaws, etc). And then

sudo  update-alternatives --config [javac|java|javadoc|etc.]

will associate that Java task/command to a particular JDK/JRE.

You may also need to set JAVA_HOME for some applications: from this answer you can use

export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")

for JREs, or

export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:jre/bin/java::")

for JDKs.

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.