Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are Java command line options to set to allow JVM to be remotely debugged?

Tags:

java

debugging

I know there's some JAVA_OPTS to set to remotely debug a Java program.

What are they and what do they mean ?

like image 440
paulgreg Avatar asked Sep 26 '08 09:09

paulgreg


People also ask

How do you set the JVM property of the server to debug?

Enable JVM DebuggingClick Java > JVM Settings tab. Under Debug Java Settings, select the Enable Debug checkbox. Provide JVM options as necessary by clicking the New button. If you substitute suspend=y, the JVM starts in suspended mode and stays suspended until a debugger attaches to it.

What is JVM command-line?

Description. The java command starts a Java application. It does this by starting the Java Virtual Machine (JVM), loading the specified class, and calling that class's main() method. The method must be declared public and static , it must not return any value, and it must accept a String array as a parameter.

What is remote JVM debug?

Remote Java Debugging is the process of debugging a Java program or application running on another machine or a server environment.

Which command-line do you use to load the JDWP agent for debugging?

-Xdebug. Enables debugging. -Xrunjdwp:<sub-options> Loads the JPDA reference implementation of JDWP.


1 Answers

Before Java 5.0, use -Xdebug and -Xrunjdwp arguments. These options will still work in later versions, but it will run in interpreted mode instead of JIT, which will be slower.

From Java 5.0, it is better to use the -agentlib:jdwp single option:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044 

Options on -Xrunjdwp or agentlib:jdwp arguments are :

  • transport=dt_socket : means the way used to connect to JVM (socket is a good choice, it can be used to debug a distant computer)
  • address=8000 : TCP/IP port exposed, to connect from the debugger,
  • suspend=y : if 'y', tell the JVM to wait until debugger is attached to begin execution, otherwise (if 'n'), starts execution right away.
like image 158
paulgreg Avatar answered Oct 02 '22 17:10

paulgreg