简体   繁体   中英

Additional debug option for runnable jar using command prompt

I know that the java -jar filename.jar is used for executing the jar file using command prompt, but could anyone please explain the following command:

java -jar filename.jar -debug

What is the exact use of the -debug in the above command?

This is not a flag for the Java Interpreter (as those should be passed before the actual class/jar).

If you execute the command-line you posted above, this will launch your filename.jar -files main class and give it's main(String[] args) -method the -debug -parameter as the second argument in the args -array.


But, there is (or was) also the -debug flag from older Java versions, which has been replaced by the -Xdebug flag . The (certainly old) manpage states that:

-debug Allows the Java debugger - jdb(1) - to attach itself to this java session. When -debug is specified on the command line java displays a password that must be used when starting the debugging session.

If a Java application is launched with the debug flag, remote-debuggers can attach to the running application and you can (for example) monitor it using JConsole

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM