从http://www.oracle.com中下载jdk:jdk-6u38-linux-x64.bin,存放到/usr/java目录 1、给权限:sudo chmod u+x/home/luowei/myapps/jdk-6u38-linux-x64.bin 2、安装jdk:sudo /home/luowei/myapps/jdk-6u38-linux-x64.bin 3、设置环境变量:sudo gedit /etc/environment #set java environment JAVA_HOME=/home/luowei/myapps/jdk/jdk1.6.0_38 PATH=$PATHJAVA_HOME/bin CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$CLASSPATH export JAVA_HOME PATH CLASSPATH 4、使上面设置的环境变量生效:#source /etc/environment 5、设置ubuntu的默认jdk,原因使因为ubuntu默认有openjdk:
Install new java source in system: sudo update-alternatives --install /usr/bin/javac javac /home/luowei/myapps/jdk/jdk1.6.0_38/bin/javac 1 sudo update-alternatives --install /usr/bin/java java /home/luowei/myapps/jdk/jdk1.6.0_38/bin/java 1 sudo update-alternatives --install /usr/bin/javaws javaws /home/luowei/myapps/jdk/jdk1.6.0_38/bin/javaws 1
Choose default java: sudo update-alternatives --config javac sudo update-alternatives --config java sudo update-alternatives --config javaws 选择对应的jdk编号,回车
6、查看当前jdk版本:java -version
来源:Ubuntu安装sun jdk过程
|