-1

我在企业 linux 4 上安装了 jdk1.6.0_16,我还在 ~/.bash_profile 中设置了 JAVA_HOME

echo $JAVA_HOME 正确显示java文件的新路径

导出 JAVA_HOME=/jdk16/jdk1.6.0_16/bin/java

bin 目录也在路径中

但是,当我执行 java -version 时,我仍然看到 java 版本“1.4.2”

发出 java -version 命令时如何查看新安装的 jdk 版本

4

4 回答 4

2
whereis java

Type that in, and it will show you the locations java is kept.

Here is a page about it

Or execute the java binary directly using: /jdk16/jdk1.6.0_16/bin/java -version

于 2009-12-31T03:26:46.533 回答
1

In addition to what PostMan said, you should also modify your PATH envvar in the following way:

export PATH=$JAVA_HOME:$PATH

put this in your bash_profile. This will guarantee you pick up the 1.60 jdk. Also your JAVA_HOME should probably be;

JAVA_HOME=/jdk16/jdk1.6.0_16/bin

that is you shouldn't put the path to the actual java executable in JAVA_HOME. It should point to the java installs bin directory.

于 2009-12-31T03:30:15.900 回答
1

Executing

which java

will tell you which jvm's executable you're running when you just run java -version.

With multiple JVMs installed, it's best to fully specify the path or set your PATH environment variable appropriately.

于 2009-12-31T03:44:53.300 回答
0
$ vi ~/.bash_profile

--> Add

export JAVA_HOME=<path to java jdk>
export PATH=$JAVA_HOME:$PATH

--> write/save

Esc + : + w

--> quit editor

Esc + : + q
于 2014-04-08T10:38:24.727 回答