Forrest logo
back to the java tool

java:tldr:36111

java: Execute a `.jar` program with debug waiting to connect on port 5005.
$ java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 -jar ${filename-jar}
try on your machine

This command is used to start a Java application with the Java Debug Wire Protocol (JDWP) agent enabled.

Here is the breakdown of the command:

  • java: This is the command to execute the Java Virtual Machine (JVM) and run Java programs.

  • -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005: This flag enables the JDWP agent with the specified configuration options:

    • transport=dt_socket: This specifies the transport mechanism to use, in this case, a socket connection.

    • server=y: This indicates that this JVM should act as the JDWP server, waiting for the debugger to connect.

    • suspend=y: This setting suspends the execution of the Java application until a debugger is connected.

    • address=*:5005: This specifies the address and port number on which the JDWP agent listens for incoming debugger connections. In this case, it listens on all network interfaces (*) on port 5005.

  • -jar ${filename-jar}: This flag tells Java to execute the specified JAR (Java Archive) file. ${filename-jar} is a placeholder for the actual filename of the JAR that should be executed.

So, when this command is executed, it starts the Java application contained in the specified JAR file while also enabling the JDWP agent. The application execution is suspended until a debugger is connected to the specified address and port.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the java tool