0

I'm trying to change the path of java_home to java-1.7.0 in a CentOS 7 machine which already has java-1.8.0 installed.

I uninstalled java-1.8.0, and used 

yum -y install java-1.7.0

to install java 1.7. However,

which java

command still points to java-1.8. How do I find the path of java 1.7 JRE in this case in order to set java_home using a bash script?

Thank you,

userDtrm
  • 533
  • 2
  • 7
  • 20

1 Answers1

0

Try setting JAVA_HOME with the new java path(eg. '/usr/local/java1.7/jdk').

export JAVA_HOME=/usr/local/java1.7/jdk

Then add the JAVA_HOME/bin to PATH variable.

export PATH=$JAVA_HOME/bin:$PATH

By default java will get installed in the ' /usr/lib/jvm ' location. So, try ls command in this path to find the required java version.

cd  /usr/lib/jvm
ls

Use this path to set the JAVA_HOME.

Sreejith
  • 506
  • 5
  • 7
  • my Java home looks like "java.home = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre". I need to know how to get where Java 1.7 is installed in the system using bash programmatically to set the path using the export command. – userDtrm Mar 24 '20 at 21:18