LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 04-11-2018, 09:38 AM   #1
dazzpowder
LQ Newbie
 
Registered: Nov 2015
Posts: 14

Rep: Reputation: Disabled
java -version and java_home


Hi All,

I have added the variables to a users .bash_profile i.e

export JAVA_HOME=/path/to/java
export PATH=$PATH:$JAVA_HOME/bin

so echo $java_home shows as it should an alterante jdk installation yet java -version still points to the old version.

what do I change so that this users java world is the new java stated in his profile?

-thanks
 
Old 04-11-2018, 10:26 AM   #2
Myk267
Member
 
Registered: Apr 2012
Location: California
Posts: 401
Blog Entries: 15

Rep: Reputation: Disabled
Quote:
Originally Posted by dazzpowder View Post
Hi All,

I have added the variables to a users .bash_profile i.e

export JAVA_HOME=/path/to/java
export PATH=$PATH:$JAVA_HOME/bin

so echo $java_home shows as it should an alterante jdk installation yet java -version still points to the old version.

what do I change so that this users java world is the new java stated in his profile?

-thanks
The examples I see put JAVA_HOME onto the front of PATH, not on the end. https://docs.oracle.com/cd/E19182-01...dk_javahome_t/ So maybe flip that around and retry?

ex:
Code:
export PATH=$JAVA_HOME/bin:$PATH

Last edited by Myk267; 04-11-2018 at 10:28 AM.
 
Old 04-11-2018, 10:38 AM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,553
Blog Entries: 15

Rep: Reputation: 1494Reputation: 1494Reputation: 1494Reputation: 1494Reputation: 1494Reputation: 1494Reputation: 1494Reputation: 1494Reputation: 1494Reputation: 1494
Running command "java" has to first find the PATH to java command (just as running "ls" has to find the PATH to ls). The JAVA* variables come into play AFTER you invoke "java". To find the one you want, modify the users' environment files (bashrc, .bash_profile, .profile, or other) so that the PATH= definition has the directory of the new java executable BEFORE the directory where the old java is.
"echo $PATH" as the the user will show you what order the directories are in now.

You don't mention what distro you are on. Some use "alternatives" to allow you to specify which java is the default to use. If you're wanting to make a global change for all users to use the new java you might want to explore that. Type "man alternatives" for more information.

Last edited by MensaWater; 04-11-2018 at 10:39 AM.
 
Old 04-11-2018, 11:38 AM   #4
dazzpowder
LQ Newbie
 
Registered: Nov 2015
Posts: 14

Original Poster
Rep: Reputation: Disabled
Thanks,

Changing to
export JAVA_HOME=/a_dir/another_dir/jre
export PATH=$JAVA_HOME/bin:$PATH

worked
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Java install: JAVA_HOME seems to be missing deretsigernu Slackware 15 09-28-2017 06:48 PM
[SOLVED] Linux Mint on Intel CPU, will the AMD Java work properly? Also JAVA_HOME nerdofdarkness Linux - Newbie 3 10-22-2013 02:10 AM
How to get/set Java version, JAVA_HOME and Classpath MughalShahzad Programming 3 07-13-2010 11:26 PM
Setting JAVA_HOME after automatic update of Java to the latest version BinDigit1 Linux - General 1 07-23-2009 07:21 PM
Java - JAVA_HOME problem after upgrade ssa2204 Linux - Newbie 5 08-24-2006 07:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 03:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration