Solved

java home path in linux

Posted on 2014-12-15
12
284 Views
Last Modified: 2014-12-24
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
Comment
Question by:D_wathi
  • 4
  • 4
  • 2
  • +2
12 Comments
 
LVL 34

Assisted Solution

by:Seth Simmons
Seth Simmons earned 250 total points
ID: 40500563
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
 
LVL 37

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40500707
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
 
LVL 62

Expert Comment

by:gheist
ID: 40501055
Do not export anything. update-alternatives java
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 86

Expert Comment

by:CEHJ
ID: 40501107
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
 
LVL 62

Accepted Solution

by:
gheist earned 250 total points
ID: 40501144
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 40501148
Some software requires JAVA_HOME be set. Presumably D_wathi has a reason for wishing to set it ..?
0
 

Author Comment

by:D_wathi
ID: 40501695
Thanks for all, can you please help in suggesting how to check it is working after setting JAVA_HOME and set path.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40501718
echo $PATH
echo $JAVA_HOME

Open in new window


(In a new terminal)
0
 
LVL 34

Expert Comment

by:Seth Simmons
ID: 40501814
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
 
LVL 62

Expert Comment

by:gheist
ID: 40502052
Since single version of java is installed, I wonder which java application is incapable of finding it
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 40502199
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
 
LVL 62

Expert Comment

by:gheist
ID: 40516547
Just for reference:
update-alternatives --list
update-alternatives --config java\*
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
There are numerous questions about how to setup an IBM HTTP Server to be administered from WebSphere Application Server administrative console. I do hope this article will wrap things up and become a reference for this task. You need three things…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question