Unable to change JRE in Katalon Runtime Engine

Hi, I am using Katalon_Studio_Engine_Windows_64-8.3.5 on Windows 10.
I need to change the jre version in katalon runtime engine to run my tests from command line. While it was easy changing it in Katalon studio and worked as expedcted, I am struggling with changing it in KRE.

I have followed the steps mentioned in Katalon docs:Set a new default JRE for test projects | Katalon Docs
However, even after setting KATALON_JAVA_HOME env var to the desired jdk home and running the katalonc test suite command, it still picks up the default jre only:
image
I also tried editing katalonc.ini file by adding “-vm C:\jdk1.7.0_21\bin\javaw.exe” at the beginning, before startup:


In this case, the katalonc exe crashes and generated log shows:

Can anyone help me with the steps to change jre version in runtime-engine? Thanks

Before hitting that “Create Topic” button, make sure to:

  • Search for similar topics to make sure it hasn’t been reported by another member;
  • Assign suitable tags to your topics (e.g. katalon-studio, web-testing, chrome, etc.)
  • And most importantly, follow the template below. :smiley:

Operating System

e.g. Windows 10/11 or MacOS Montery

Katalon Studio version

e.g. version 8.x.x

Log Folder:

  • Windows logs folder: Katalon Studio folder>\config\.metadata\.log
  • MacOS logs folder: file:///Applications/Katalon%20Studio.app/Contents/MacOS/config/.metadata/.plugins/org.eclipse.ui.workbench/log

Environment (for Web Testing)

  • Browser & browser version

Environment (for Mobile Testing)

  • Browser and Browser version

Environment (for Mobile testing)

  • Appium version
  • Mobile platform/version under test: (for example: iOS 11 or Android 7)
  • Real device or emulator/simulator: (for example: iPhone 6s real or Nexus 6 simulator)
  • Xcode version (for iOS): (for example: Xcode 8 or Xcode 11)
  • Appium Logs: \.appium
  • Application file (.apk/.ipa): (if possible)

Steps to reproduce

Please include an SSCCE (Short, Self Contained, Correct [compilable] example) description http://sscce.org/

If it’s not possible to provide the web page link (for web), please consider creating a reproducible page on https://jsfiddle.net/

Please also provide your test scripts if possible.

Expected Behavior

Actual Behavior

Screenshots / Videos (please attach screenshots or videos if necessary to reproduce the issue)

You cannot do that in the katalon.ini file since it is not a script, but a config file.
It breaks because you altered the file structure.
Now, provided you follow the instructions right … it should work.
Read the Notes carefully from the doc, e.g:

This change applies to the JRE used to run your test projects, not the JRE used to run Katalon Studio.

So, what you see in the log you posted in the first pic it is the embedded java version used to run KRE himself (and I think only openjdk8 is currently supported)
To check the java version used to actually run the tests, follow the instructions in the last Note:

  • In case you want to check which Java version the test project is developed with, add the following script to a test case, then run it and see the log.
println System.getProperty('java.version')

Thanks for your reply, I added the “println System.getProperty(‘java.version’)” to my test case and on running it in Katalon Studio, it prints the expected java version which I have set, i.e. 17.0.3

But when I run the same test suite in command line using KRE, I am getting this issue:
com/test/TestClass has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0”, before the test script execution even begins.

I have followed the steps mentioned in Set a new default JRE for test projects | Katalon Docs
I perform the following steps

  • set KATALON_JAVA_HOME=“C:\Program Files\Amazon Corretto\jdk17.0.3_6” (same jdk path that I use in Katalon studio)

  • katalonc…

I am using a class in my test case whose jar is compiled with java 11, and hence the issue

I got the same issue in Katalon studio also, but it got resolved after I changed the selected jre from preferences window.
But I am still getting this issue in KRE, indicating that it is not picking up the desired jre whose path I have assigned to the KATALON_JAVA_HOME env var for test suite execution.

@duyluong @ThanhTo any clues why KRE is behaving like that?
Is the KATALON_JAVA_HOME the right env variable to be set?

@aasheesh.jha you can also try do add a certain print in your script to check if the env variable is properly set, e.g:

println System.getenv("KATALON_JAVA_HOME")

Are you running KRE from cmd or powershell? If I remember it right, in powershell set may not work all the time, you have to use a different command (sorry, I am not using windows currently)
As an alternative, you can try to set it from GUI.

@aasheesh.jha

You can try deleting the bin folder and try again

1 Like

I am running KRE from cmd only, not powershell.
I tried your suggestion of printing env_var in test script to see its content, and removed the import of the class compiled with higher java version so that test suite atleast executes:


And it prints the expected java version and environment variable.
Though the log at beginning still prints java 1.8 only.
But when I run my complete test case with same settings with the required imports from the jar, it crashes with the following message before test script execution:

I have tried running after deleting the bin folder in my test project but the result is still the same.

As I mentioned, that is the Java version usede to run KRE himself. Ignore it. Your desired JRE seems to be properly picked by the runtime.

In addition to the bin folder you may have to delete also the Libs folder and the ‘hidden’ .classpath and .project files which are generated at compile time.
Make sure the project is not opened in Katalon Studio when you do this.

A shortcut for the above is, open your project in Katalon Studio and go to Project > Close and Cleanup.

Thanks for all your help. I was able to solve the issue I was getting.
What I observed was, when I was importing and using the class from the java 17 compiled jar in the Test Listener, I was getting the error:
com/test/TestClass has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
However, if I remove the import (and usage) of this class from test listener, this error message disappears. I was able to verify it in a separate project that merely importing this class(from the same jar) in test listener causes the mentioned error to appear.
Also, if I import and use the class with the same code, in any other file, like a keyword or a test script, it works without an issue and executes successfully, and the error does not show up. So I decided to use a keyword instead of the test listener for my purpose.
I don’t understand why I get this issue with the exact same code from test listener, and why not other files.