java_home和path,我设置了JAVA_HOME和PATH变量,但是java -version仍然显示旧的

I am using Linux Mint Cinnamon 14. I have set the $JAVA_HOME and $PATH environment variables in ~/.profile as follows:

export JAVA_HOME=/home/aqeel/development/jdk/jdk1.6.0_35

export PATH=/home/aqeel/development/jdk/jdk1.6.0_35/bin:$PATH

I then did source ~/.profile to make the proper changes.

When I execute java -version command to check the active java version, it shows the default (already installed open-jdk) java version. How can I override the default open-jdk with the one I downloaded?

UPDATE:

which java says /usr/bin/java

$JAVA_HOME/bin/java -version says 'Permission Denied'

sudo $JAVA_HOME/bin/java -version (asks for password, then) says Command not found

but cd $JAVA_HOME/bin, and ls shows that it is right directory.

解决方案

While it looks like your setup is correct, there are a few things to check:

The output of env - specifically PATH.

which java tells you what?

Is there a java executable in $JAVA_HOME\bin and does it have the execute bit set? If not chmod a+x java it.

I trust you have source'd your .profile after adding/changing the JAVA_HOME and PATH?

Also, you can help yourself in future maintenance of your JDK installation by writing

export JAVA_HOME=/home/aqeel/development/jdk/jdk1.6.0_35

export PATH=$JAVA_HOME/bin:$PATH

instead. Then you only need to update one env variable when you setup the JDK installation.

Cheers,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值