Solved

java home path in linux

Posted on 2014-12-15
12
274 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
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 61

Expert Comment

by:gheist
ID: 40501055
Do not export anything. update-alternatives java
0
 
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 61

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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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 61

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 61

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determine Who is Runnig my Bash Shell Script 4 62
web services creation SOAP vs REST 5 20
couple of eclipse 5 23
servlet filter example 37 43
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now