java linux下的java版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2165961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 19:47:51  来源:igfitidea点击:

java version in linux

javalinuxclasspath

提问by user229432

# which java
/usr/bin/which: no java in (/usr/local/jdk/jdk1.5.0_10/bin/java:/usr/local/jdk/jdk1.5.0_10/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin)

I installed java in /usr/local/jdk/jdk1.5.0_10 but cannot run java -version

我在 /usr/local/jdk/jdk1.5.0_10 中安装了 java 但无法运行 java -version

I get this

我明白了

$ java -version
-bash: /usr/bin/java: No such file or directory

this is red hat linux

这是红帽Linux

回答by Bill

It's not in your path.

它不在你的道路上。

use

利用

export PATH=$PATH:/usr/local/jdk/jdk1.5.0_10/bin

export JAVA_HOME=/usr/local/jdk/jdk1.5.0_10

Look at ~/.bash_profile for where to define this permanatly.

查看 ~/.bash_profile 在哪里永久定义它。

回答by Shainal

Must be in local path of java before running to see what version is installed. Use find / -name java?(this will list anything with java on the server copy the path ). path should end with..../jre/bin/java copy full path.

运行之前必须在java的本地路径下才能看到安装了什么版本。使用 find / -name java?(这将列出服务器上带有 java 的任何内容复制路径)。路径应以..../jre/bin/java 复制完整路径结尾。

Open Java location of the path you copied above, remove java at the end you path then enter, Enter command below:
./Java -Version

打开上面复制的路径的Java位置,删除路径末尾的java然后输入,在下面输入命令:
./Java -Version

回答by Dominik Sandjaja

Can you do ls /usr/local/jdk/jdk1.5.0_10/binAnd why is /usr/local/jdk/jdk1.5.0_10/bin/javain your path?

你能做到 吗?ls /usr/local/jdk/jdk1.5.0_10/bin为什么/usr/local/jdk/jdk1.5.0_10/bin/java在你的道路上?