Search code examples
karatesikulisikuli-x

[karate][standalone] how to add sikulixapi.jar to classpath by default using karate-config.js?


Karate version: 0.9.5.RC3
IDE : Visual Studio Code 1.38.1
OS: Windows 10 Ent

I have downloaded the zip and was running Native Automation example with SikuliX using the karate standalone jar.

Now to execute the tests I need to use below command
java -cp karate.jar;sikulixapi.jar com.intuit.karate.Main %*

Instead of this, I want to use the karate-config.js file to specify the classpath in which sikulixapi.jar plus some other jar is already present.

Also, one should be able to run tests directly using the below command.
java -jar karate.jar calc.feature
or using the Karate Runner plugin in Visual Studio Code.

BTW a great thanks to the creators of KarateDSL


Solution

  • Unfortunately that is not possible. Setting the classpath is such a fundamental operation that it has to be done when the JVM is started. The recommended approach is you edit a batch file to do this, see this answer for details: https://stackoverflow.com/a/58398958/143475

    There are some hacks you can try such as this one: https://stackoverflow.com/a/252967/143475