设置了JAVA_HOME和PATH,但java -version仍然显示旧的 [英] JAVA_HOME and PATH are set but java -version still shows the old one
问题描述
我正在使用Linux Mint Cinnamon 14.我已经在<设置了 $ JAVA_HOME
和 $ PATH
环境变量code>〜/ .profile 如下:
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
然后我做 source~ / .profile
进行适当的更改。
I then did source ~/.profile
to make the proper changes.
当我执行 java -version
命令来检查活动的java版本时,它显示了默认的(已经安装的open-jdk)java版本。如何使用我下载的版本覆盖默认的open-jdk?
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?
更新:
哪个java
说/ usr / bin / java
which java
says /usr/bin/java
$ JAVA_HOME / bin / java -version
说'Permission Denied'
$JAVA_HOME/bin/java -version
says 'Permission Denied'
sudo $ JAVA_HOME / bin / java -version
(请求密码,然后说)找不到命令
sudo $JAVA_HOME/bin/java -version
(asks for password, then) says Command not found
但是 cd $ JAVA_HOME / bin
,和 ls
显示它是正确的目录。
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:
-
env $ c的输出$ c> - 特别是
PATH
。 -
哪个java
告诉你什么? -
$ JAVA_HOME \ bin
中是否有java
可执行文件它有执行位设置?如果不是chmod a + x java
it。
- The output of
env
- specificallyPATH
. which java
tells you what?- Is there a
java
executable in$JAVA_HOME\bin
and does it have the execute bit set? If notchmod a+x java
it.
我相信你有<添加/更改 JAVA_HOME
后,code>来源'你的 .profile
和 PATH
?
I trust you have source
'd your .profile
after adding/changing the JAVA_HOME
and PATH
?
此外,您可以通过编写
export JAVA_HOME=/home/aqeel/development/jdk/jdk1.6.0_35
export PATH=$JAVA_HOME/bin:$PATH
。然后,您只需在设置JDK安装时更新一个env变量。
instead. Then you only need to update one env variable when you setup the JDK installation.
干杯,
这篇关于设置了JAVA_HOME和PATH,但java -version仍然显示旧的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!