Solved

java home path in linux

Posted on 2014-12-15
12
266 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

20 Experts available now in Live!

Get 1:1 Help Now