0

After installing two versions of java in rhel how do I point my program to one of those specific java file?

The java files that were installed were:

java-1.7.0-oracle-src-1.7.0.79-1jpp.1.el7_1.x86_64
java-1.8.0-oracle-javafx-1.8.0.45-1jpp.2.el7_1.x86_64
java-1.8.0-oracle-devel-1.8.0.45-1jpp.2.el7_1.x86_64
java-1.8.0-oracle-src-1.8.0.45-1jpp.2.el7_1.x86_64
java-1.7.0-oracle-javafx-1.7.0.79-1jpp.1.el7_1.x86_64
java-1.8.0-oracle-jdbc-1.8.0.45-1jpp.2.el7_1.x86_64
java-1.7.0-oracle-devel-1.7.0.79-1jpp.1.el7_1.x86_64
java-1.7.0-oracle-jdbc-1.7.0.79-1jpp.1.el7_1.x86_64
java-1.8.0-oracle-plugin-1.8.0.45-1jpp.2.el7_1.x86_64
java-1.7.0-oracle-1.7.0.79-1jpp.1.el7_1.x86_64
java-1.8.0-oracle-1.8.0.45-1jpp.2.el7_1.x86_64
java-1.7.0-oracle-plugin-1.7.0.79-1jpp.1.el7_1.x86_64
1

1 Answer 1

1

Do you mean choosing what version of Java to use?

Some Linux distributions rely on update-alternatives tool to control what specific binary to use when multiple versions of it are installed. It works by setting symbolic links. For instance in my system, after installing openjdk, a symbolic link at:

/usr/bin/java

was created linked to the real java binary at:

/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java

If update-alternatives is installed in your system, and the installation of Java updated its status correctly, you can choose the version of Java interactively by doing:

sudo update-alternatives --config java

Another approach: simply set JAVA_HOME and/or PATH environment variables right before you execute your command to switch between one or other Java version.

1
  • I read up on that, however the problem is i'll have programs running both java versions at the same time. My current work around is by using this command: { /opt/opennms/bin/runjava -S /usr/lib/jvm/java-1.8.0-oracle-1.8.0.45-1jpp.2.el7_1.x86_64/bin/java } as a way to link to the java binary file.
    – Xavier
    May 28, 2015 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.