Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

java home path in linux

Hi

I have installed rhel7 and java-1.7.0-oracle , below details
find / -name "java"
/etc/alternatives/java
/etc/pki/java
/etc/pki/ca-trust/extracted/java
/etc/java
/var/lib/alternatives/java
/usr/bin/java
/usr/lib/jvm-exports/java
/usr/lib/jvm/java-1.7.0-oracle-1.7.0.72-1jpp.2.el7.x86_64/jre/bin/java
/usr/lib/jvm/java-1.7.0-oracle-1.7.0.72-1jpp.2.el7.x86_64/bin/java
/usr/lib/jvm/java
/usr/lib/java
/usr/share/swig/2.0.10/java
/usr/share/java
[root@crm1 opt]#
------------------
please suggest  how to set JAVA_HOME and export path by considering the above details, also how to test it is working
export JAVA_HOME=
export PATH=

thanks in advance
0
D_wathi
Asked:
D_wathi
  • 4
  • 4
  • 2
  • +2
2 Solutions
 
Seth SimmonsSr. Systems AdministratorCommented:
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-oracle-1.7.0.72-1jpp.2.el7.x86_64/
export PATH=$PATH:/usr/lib/jvm/java-1.7.0-oracle-1.7.0.72-1jpp.2.el7.x86_64/

see if that works for you
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-oracle-1.7.0.72-1jpp.2.el7.x86_64
export PATH=${PATH}:${JAVA_HOME)/bin

Test: java -version
0
 
gheistCommented:
Do not export anything. update-alternatives java
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
CEHJCommented:
Do not export anything. update-alternatives java
But that won't set JAVA_HOME for you

First and second answers fine. Second marginally better (apart from the typo ;)) as variables more portable. But this is better as it avoids problems from Java (unwittingly) already being present in PATH

export PATH=${JAVA_HOME}/bin:${PATH}

Open in new window

0
 
gheistCommented:
You do not have to set JAVA_HOME unless always up-to-date /usr/bin/java is too good for you (Oracle upgrades java every three months declaring all previous versions unsupported)
0
 
CEHJCommented:
Some software requires JAVA_HOME be set. Presumably D_wathi has a reason for wishing to set it ..?
0
 
D_wathiAuthor Commented:
Thanks for all, can you please help in suggesting how to check it is working after setting JAVA_HOME and set path.
0
 
CEHJCommented:
echo $PATH
echo $JAVA_HOME

Open in new window


(In a new terminal)
0
 
Seth SimmonsSr. Systems AdministratorCommented:
depending on your setup, a new terminal window may not have it
i usually put that in /etc/profile but you can put for individual user profile then logout and login again

then do which java and it will show the path to the binary
you can also do java -version
0
 
gheistCommented:
Since single version of java is installed, I wonder which java application is incapable of finding it
0
 
CEHJCommented:
which java

Open in new window

of course can be independent of $JAVA_HOME (which is part of the point of that variable) so to make sure you have got things set up in the way you want, the following should work and return the correct version

$JAVA_HOME/bin/java -version

Open in new window

0
 
gheistCommented:
Just for reference:
update-alternatives --list
update-alternatives --config java\*
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now