I cannot get command-line debugging with jdb to work on a Cucumber/Java jar file. I looked at this SO question for example, and so far nothing has worked.
- When I run the cucumber feature file from IntelliJ, it works just fine.
- I compiled the program according to the local directions, and that finished successfully.
- When I run the compiled jar file with
java -jar runJar.jar
, everything works just fine. When I run
jdb runJar.jar
, I get the jdb prompt:Initializing jdb ...
but when I try to run the Main-Class, it fails:
> run MainRunner
run MainRunner
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started: Error: Could not find or load main class MainRunner
The application exited
I know that "MainRunner" is the correct class because that's the name of the "Main class:" in IntelliJ and also because I unzipped the jar file using this command:
unzip -c MyJar.jar META-INF/MANIFEST.MF | grep 'Main-Class
and it reports Main-Class: com.XXXXX.sdt.framework.runner.MainRunner
as the Main-Class.
If instead
run MainRunner
I typerun com.XXXXX.sdt.framework.runner.MainRunner
, then I get the error:VM Started: Error: Could not find or load main class com.XXXXX.sdt.framework.runner.MainRunner
If I startup a JVM and then attach to it with:
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044 -jar runJar.jar
and
jdb -attach 1044
and resume after the main1 prompt, I get the error
Exception occurred: java.lang.StringIndexOutOfBoundsException (uncaught)"thread=main", java.lang.String.charAt(), line=658 bci=21
The Java docs on jdb imply that this should just work, so I'm not sure where to go from here.