Feather Background Waves Background
Skip to main content
Feather Background Waves Background
Feather Background Waves Background
  1. JMeter in English/

Switching Java Versions on Mac

Beginner - This article is part of a series.
Part 5: This Article

recording

One day, your manager, alerted to your extensive experience with JMeter, asks you to urgently develop several scripts to test a website. Being a very astute engineer, you decide to consult our blog where our expert friend Antonio clarifies that the most appropriate version for JMeter is Java 1.8.

Immediately after verifying that your MacBook has Java 11 installed (which is required by another application), the following questions come to mind:

  1. Should I replace the existing version of Java with the version required by JMeter?
  2. Once the JMeter project is finished, do I have to reinstall version 11?
  3. Is it possible to have both (or more) versions at the same time?

Don’t worry. Here are the answers: No, No, and…

Yes, it is possible to have more than one version of the JDK, and consequently, different versions of the Java runtime required by JMeter.

We start by downloading the JDK 1.8+ version for MacOS from this site:

https://www.oracle.com/technetwork/java/javase/downloads/

Note: The different versions of the Java JDK will be located on macOS in the following directory: /Library/Java/JavaVirtualMachines

After installing this version, we enable it (using a terminal) as follows:

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_x.jdk/Contents/Home
 java -version
 ./jmeter.sh

Done. JMeter will use Java version 1.8, but only for the session, without interfering with any existing Java versions.

Some might say: “But Mr. Californian, this is a lot to remember!” And they’re right!

Inspired by the law of least effort, I created this “one-liner” that includes the aforementioned commands.

JAVA_HOME="$(/usr/libexec/java_home -v 1.8.\*)"; java -version; ./jmeter.sh &

Finally, for fans of the aforementioned law, I present an alias (bash) that, once incorporated into the .profile file, will allow you to invoke JMeter with a short name: “jm"

alias jm='JAVA_HOME="$(/usr/libexec/java_home -v 1.8.\*)"; java -version; ./jmeter.sh &

Greetings. Next blog: Switching between different versions of JMeter.



Beginner - This article is part of a series.
Part 5: This Article