Sometimes, while trying to automate a Java AUT the hooking fails and the following error is shown:
Either the application could not be started or it was started but Squish failed to hook into it.
In such cases it is possible that the AUT executable or binary is actually a custom launcher application.
The launcher applications are small executable programs which load and start a Java Application. Squish sets some environment variable at the starting of the AUT in which additional JVM arguments are placed and passes these arguments to the launcher application. When for some reason the hooking does not work, we then have to provide these arguments manually.
I will take NetBeans IDE 8.1 as an example to explain how to pass the JVM arguments manually.
Because NetBeans IDE supports _JAVA_OPTIONS, I will first unset _JAVA_OPTIONS to simulate the hooking issue.
Now, in order for Squish to be able to hook into the application we will create a batch file called „Netbeans.bat“ and place it in my Home folder. This batch file will have the following content:
set _JAVA_OPTIONS= cd "C:\Users\Neha\Netbeans\NetBeans 8.1\bin" netbeans "-J%SQUISH_JAVA_DEF_1%" "-J%SQUISH_JAVA_DEF_2%" "-J%SQUISH_JAVA_DEF_3%" "-J%SQUISH_JAVA_DEF_4%" "-J%SQUISH_JAVA_DEF_5%" "-J%SQUISH_JAVA_DEF_6%" "-J-Dsquish.bcel=%SQUISH_PREFIX%\lib\bcel.jar"
Which basically unsets the _JAVA_OPTIONS environment variable and then starts the netbeans.exe with the JVM arguments.
Once this is done, then in the test suite’s settings we will set Netbeans.bat as the Application Under Test.
This is how hooking can be managed by providing additional Java VM parameters manually to a launcher created by NetBeans. The way of passing these parameters can differ depending on the technology on which the launcher is based.