简体   繁体   English

红帽企业Linux

[英]linux red hat enterprise linux

I installed jdk1.6.0_16 on enterprise linux 4 and I also set teh JAVA_HOME in my ~/.bash_profile 我在企业Linux 4上安装了jdk1.6.0_16,并且还在〜/ .bash_profile中设置了JAVA_HOME。

echo $JAVA_HOME correctly shows the new path of the java file echo $ JAVA_HOME正确显示Java文件的新路径

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

The bin directory is also int he path bin目录也位于路径中

However when I do java -version I still see java version "1.4.2" 但是,当我执行java -version时,仍然看到Java版本“ 1.4.2”

How do I see newly installed jdk verion when i issue java -version command 我发出java -version命令时如何查看新安装的jdk版本

whereis java

Type that in, and it will show you the locations java is kept. 输入它,它将显示您保存java的位置。

Here is a page about it 这是关于它的页面

Or execute the java binary directly using: /jdk16/jdk1.6.0_16/bin/java -version 或直接使用以下/jdk16/jdk1.6.0_16/bin/java -version执行Java二进制文件: /jdk16/jdk1.6.0_16/bin/java -version

In addition to what PostMan said, you should also modify your PATH envvar in the following way: 除了PostMan所说的以外,您还应该通过以下方式修改PATH envvar:

export PATH=$JAVA_HOME:$PATH

put this in your bash_profile. 把它放在你的bash_profile中。 This will guarantee you pick up the 1.60 jdk. 这将确保您获得1.60丹麦克朗。 Also your JAVA_HOME should probably be; 您的JAVA_HOME也应该是;

JAVA_HOME=/jdk16/jdk1.6.0_16/bin

that is you shouldn't put the path to the actual java executable in JAVA_HOME. 那就是您不应该将路径放置到JAVA_HOME中实际的Java可执行文件中。 It should point to the java installs bin directory. 它应该指向java install bin目录。

Executing 执行中

which java

will tell you which jvm's executable you're running when you just run java -version. 当您只运行java -version时,它将告诉您正在运行哪个jvm的可执行文件。

With multiple JVMs installed, it's best to fully specify the path or set your PATH environment variable appropriately. 安装了多个JVM之后,最好完全指定路径或适当地设置PATH环境变量。

$ vi ~/.bash_profile

--> Add ->添加

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

--> write/save ->写入/保存

Esc + : + w

--> quit editor ->退出编辑器

Esc + : + q

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM