找到JAVA_HOME并在RHEL上设置它 [英] Find JAVA_HOME and set it on RHEL

查看:113
本文介绍了找到JAVA_HOME并在RHEL上设置它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在RHEL机器上安装了java。现在,我正在尝试运行一个需要设置JAVA_HOME变量的程序。找出我的java安装的安装目录然后设置JAVA_HOME的最佳方法是什么?以下是运行java-版本的结果:

I had installed java a while ago on my RHEL machine. Now, I'm trying to run a program that requires the JAVA_HOME variable to be set. What is the best way to figure out the installation directory of my java installation and then set JAVA_HOME? Here are the results of running java- version :

java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

我有一个/ usr / lib / jvm目录,但它是空的。

I have a /usr/lib/jvm directory, but it is empty.

推荐答案

首先,从命令行尝试 echo $ JAVA_HOME 。由于 java 已经在您的路径上,因此可以设置 JAVA_HOME

First, try echo $JAVA_HOME from the command line. Since java is on your path already, JAVA_HOME may be set.


找出我的java安装的安装目录的最佳方法是什么

What is the best way to figure out the installation directory of my java installation

运行命令哪个java 会指向你安装 java 的位置。

Running the command which java will point you to where java is installed.


然后设置JAVA_HOME

and then set JAVA_HOME

您可以编辑〜/。 bashrc 〜/ .bash_profile ,或 / etc / profile 设置 JAVA_HOME 。在〜/ etc / profile 中设置它会将其设置为系统范围,这可能不是你想要的。为了举例说明的输出,其中java /opt/jdk_1.7.0_25 ,那你就是只需将导出JAVA_HOME = / opt / jdk_1.7.0_25 添加到〜/ .bashrc 〜/ .bash_profile 然后运行 source~ / .bashrc (或 source~ / .bash_profile 如果你在那里设置它。)

You can edit ~/.bashrc, ~/.bash_profile, or /etc/profile to set JAVA_HOME. Setting it in ~/etc/profile will set it system wide, and this is probably not what you want. Say for the sake of example the output of which java is /opt/jdk_1.7.0_25, then you'd just add export JAVA_HOME=/opt/jdk_1.7.0_25 to ~/.bashrc or ~/.bash_profile and then run source ~/.bashrc (or source ~/.bash_profile if you set it there).

注意,在这种情况下, java PATH 但在某些情况下你需要添加 export PATH = $ PATH:$ JAVA_HOME / bin 来添加 JAVA_HOME 变量到 PATH

Note that in this case, java is on the PATH but in some cases you'd need to add export PATH=$PATH:$JAVA_HOME/bin to add the JAVA_HOME variable to the PATH.

这篇关于找到JAVA_HOME并在RHEL上设置它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆