Linux下JDK 升级印象

1.实验没成功的
chmod 755 jdk-6u2-ea-bin-b02-linux-i586-12_apr_2007-rpm.bin

4. Then run it:
./jdk-6u2-ea-bin-b02-linux-i586-12_apr_2007-rpm.bin

You will need to type yes to indicate your acceptance to their agreement and the installation will complete on its own. Unfortunately you are not yet done. Type java -version on the command line and you will see that it still points to the crappy old JVM from gcj.

5. Now you need to find the actual location of your JDK installation and indicate to Fedora to accept your choice.

Type the following:
updatedb;locate javac |grep bin

You will see an entry like this:
/usr/java/jdk1.6.0_02/bin/javac

Here /usr/java/jdk1.6.0_02 is the actual JAVA_HOME for your machine. Note this as you will need it to run the future commands.

Now you need to run the alternatives command to instruct Fedora to recognize Sun's JVM.
alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_02/bin/java 100
alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_02/bin/jar 100
alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_02/bin/javac 100

You can do this for other Java executables too, should you need them, following the same pattern.

Note: If alternatives is not in your path then use locate alternatives to locate it.

Finally you should configure alternative to use Sun's JVM as the default JVM. To do this type:
/usr/sbin/alternatives --config java

This will present you with at least 2 options. Choose the one for Sun's JVM. Similarly repeat the process for other commands.

Now you are done configuring Fedora for the most part. Type java -version and you should see something like this:

java version "1.6.0_02-ea"
Java(TM) SE Runtime Environment (build 1.6.0_02-ea-b02)
Java HotSpot(TM) Client VM (build 1.6.0_02-ea-b02, mixed mode, sharing)
-----------------------------------------------------------

2.实验成功的,可能不太优雅
到/etc/profile下
export JAVA_HOME=/usr/java/jdk1.6.0_16
export JAVA_BIN=/usr/java/jdk1.6.0_16/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH

apache-tomcat-6.0.20
CATALINA_BASE=/usr/local/apache-tomcat-6.0.20
CATALINA_HOME=/usr/local/apache-tomcat-6.0.20
PATH=$PATH:$CATALINA_HOME/bin
export CATALINA_BASE CATALINA_HOME PATH

java -version显示的版本时1.4,这里就出现了冲突,那么怎样让高版本的jdk生效呢?

alternatives –install /usr/bin/java java /usr/java/jdk1.6.0_12/bin/java 3000(红色代表的是安装jdk的路径,3000代表自己给该版本的jdk设置的优先级应该与系统自带的优先级不同)

alternatives –display java

alternatives –config java

alternatives –install /usr/bin/javac javac /usr/java/jdk1.6.0_12/bin/javac 3000

alternatives –display javac //显示当前系统中的javac共有几个版本

alternatives –config javac//配置javac选择较高版本的javac生

可能两个都要设置吧? :roll:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值