2

I need to change JVM implementation to compare which one is more suitable for requirements I need to meet. How can I achieve this? Specifically on GNU/Linux or MacOS. Is there a way to set JVM implementation when running java program with java console command? Or maybe I need to change some lib file that contains JVM implementation? Help would be appreciated.

Bashir
  • 2,057
  • 5
  • 19
  • 44
NikitoZZZ
  • 33
  • 7

2 Answers2

0

When you have multiple JVMs on your machine, you can simply qualify which one you want, when you execute the java command.

At least the Oracle JVM on Windows works like that. I haven't tried on Linux, or with any of the others, but the JVM doesn't need to be on the PATH, you can just qualify which one you want.

See my answer to another question for examples of how that works.

Andreas
  • 154,647
  • 11
  • 152
  • 247
0

It is easy to have multiple JVM implementations on a machine, you simply put each one in its own directory. Personally, I use /opt on Linux but you can choose where to put them.

Then, all you need to do is change your PATH environment variable to ensure that the first directory in the list that has a java executable is the one you want to use, e.g.

PATH=/opt/JDK8/bin:$PATH

You can also set the JAVA_HOME environment variable but that does not directly impact which JVM is used, it is just a convention used by other applications (like Tomcat). By doing this you can set your PATH once,

PATH=$JAVA_HOME/bin:$PATH

and then just change the JAVA_HOME variable to reflect which version of Java you want to use.

This works on both Linux and Mac (which is a UNIX based OS).

Speakjava
  • 3,177
  • 13
  • 15