java home path in linux


I have installed rhel7 and java-1.7.0-oracle , below details
find / -name "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
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Seth SimmonsSr. Systems AdministratorCommented:
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-oracle-
export PATH=$PATH:/usr/lib/jvm/java-1.7.0-oracle-

see if that works for you
Gerwin Jansen, EE MVETopic Advisor Commented:
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-oracle-
export PATH=${PATH}:${JAVA_HOME)/bin

Test: java -version
Do not export anything. update-alternatives java
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

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

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)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Some software requires JAVA_HOME be set. Presumably D_wathi has a reason for wishing to set it ..?
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.
echo $PATH

Open in new window

(In a new terminal)
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
Since single version of java is installed, I wonder which java application is incapable of finding it
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

Just for reference:
update-alternatives --list
update-alternatives --config java\*
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.