Install the JDK
- Download he 32bit or 64bit Linux "compressed binary file" - it has a ".tar.gz" file extension i.e. "[java-version]-i586.tar.gz" for 32bit and "[java-version]-x64.tar.gz" for 64bit
- Uncompress it
tar -xvf jdk-7u2-linux-i586.tar.gz
(32bit)
tar -xvf jdk-7u2-linux-x64.tar.gz
(64bit)
- Now move the JDK 7 directory to
/usr/lib
sudo mkdir -p /usr/lib/jvm sudo mv ./jdk.1.7.0_02 /usr/lib/jvm/jdk1.7.0
- Now run
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
- This will assign Oracle JDK a priority of 1, which means that installing other JDKs will replace it as the default. Be sure to use a higher priority if you want Oracle JDK to remain the default.
- Correct the file ownership and the permissions of the executables:
sudo chmod a+x /usr/bin/java sudo chmod a+x /usr/bin/javac sudo chmod a+x /usr/bin/javaws sudo chown -R root:root /usr/lib/jvm/jdk1.7.0N.B. remember - Java JDK has many more executables that you can similarly install as above.
java
, javac
, javaws
are probably the most frequently required.This answer lists the other executables available.
- Run
sudo update-alternatives --config javaYou will see output similar one below - choose the number of jdk1.7.0 - for example
3
in this list:$sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
3 /usr/lib/jvm/jdk1.7.0/jre/bin/java 3 manual mode
Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/jdk1.7.0/jre/bin/java to provide /usr/bin/java (java) in manual mode.
Check the version of you new JDK 7 installation:java -version
java version “1.7.0”
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode)
Repeat the above for:sudo update-alternatives --config javac
sudo update-alternatives --config javaws
參考自: http://askubuntu.com/questions/55848/how-do-i-install-oracle-java-jdk-7
沒有留言:
張貼留言