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.
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 type run 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 main 1 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.
Did you notice that you are running runJar.jar
but checked for the Main class in MyJar.jar
?
If you are using a JAR file as an application packaging, you need the Main-Class
in that jar file, not in one of the jar files on your path.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.