[转]升级到ubuntu 11.10之后,由于库里没有sun-java6-jdk,需要自行安装。因此,到Oracle网站下载了Java 6u27(为什么不下java7呢?因为目前支持的软件不多,另外如果真要的话,也可以很方便的切换到Java7),然后就可以开始手动安装了。
首先创建Java的目录,然后将下载下来的文件解压到该目录中:
$ sudo cp jdk-6u27-linux-i586.bin /usr/lib/jvm
$ cd /usr/lib/jvm
$ sudo ./jdk-6u27-linux-i586.bin
$ sudo mv jdk1.6.0_27/ java-1.6.0_27-sun/
$ sudo ln -s java-1.6.0_27-sun java-6-sun
$ sudo rm jdk-6u27-linux-i586.bin
其次设置环境变量,主要是PATH、CLASSPATH和JAVA_HOME,注意PATH最后所添加的bin目录:
$ sudo vi /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/u
sr/lib/jvm/java-6-sun/bin"
CLASSPATH="/usr/lib/jvm/java-6-sun/lib"
JAVA_HOME="/usr/lib/jvm/java-6-sun"
然后就是要告诉系统,我们使用的sun的JDK,而非OpenJDK了:
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-6-sun/bin/java 300
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/java/java-6-sun/bin/javac 300
$ sudo update-alternatives --config java
有 2 个候选项可用于替换 java (提供 /usr/bin/java)。
选择 路径 优先级 状态
------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 自动模式
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 手动模式
* 2 /usr/lib/jvm/java-6-sun/bin/java 300 手动模式
要维持当前值[*]请按回车键,或者键入选择的编号:2
如上所示,这样就设置好了要使用的java了。最后我们验证一下:
$ java -version
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) Server VM (build 20.2-b06, mixed mode)
打完收功!
wonderful5115 于 2012-05-06 00:26:22发表:
值得学习!
于 2012-02-27 23:22:29发表:
abc@ubuntu:~/usr/java$ sudo ./jdk-6u31-linux-x64-rpm.bin
[sudo] password for libz:
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
inflating: jdk-6u31-linux-amd64.rpm
inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm
inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
rpm: RPM should not be used directly install RPM packages, use Alien instead!
rpm: However assuming you know what you are doing...
error: Failed dependencies:
/bin/basename is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/cat is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/cp is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/gawk is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/grep is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/ln is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/ls is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/mkdir is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/mv is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/pwd is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/rm is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/sed is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/sort is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/touch is needed by jdk-2000:1.6.0_31-fcs.x86_64
/usr/bin/cut is needed by jdk-2000:1.6.0_31-fcs.x86_64
/usr/bin/dirname is needed by jdk-2000:1.6.0_31-fcs.x86_64
/usr/bin/expr is needed by jdk-2000:1.6.0_31-fcs.x86_64
/usr/bin/find is needed by jdk-2000:1.6.0_31-fcs.x86_64
/usr/bin/tail is needed by jdk-2000:1.6.0_31-fcs.x86_64
/usr/bin/tr is needed by jdk-2000:1.6.0_31-fcs.x86_64
/usr/bin/wc is needed by jdk-2000:1.6.0_31-fcs.x86_64
/bin/sh is needed by jdk-2000:1.6.0_31-fcs.x86_64
Installing JavaDB
rpm: RPM should not be used directly install RPM packages, use Alien instead!
rpm: However assuming you know what you are doing...
error: Failed dependencies:
/bin/sh is needed by sun-javadb-core-10.6.2-1.1.i386
Done.
龙的传人sq 于 2011-10-24 11:46:31发表:
看不大懂哎
nkhelloworld 于 2011-10-22 14:19:53发表:
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/java/java-6-sun/bin/javac 300
这句有错误吧,第二个路径中得“java”应为JVM
linuxunix 于 2011-10-14 11:57:01发表:
用java没饭吃
rootloong 于 2011-10-11 00:41:07发表:
- -好吧,学习一下