OS
Windows 10 64bit
Java
> java --version
openjdk 11.0.3 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)
Folder structure
> tree /f
├─build
│ └─classes
│ └─java
│ └─main
│ Hoge.class
└─src
└─main
└─java
Hoge.java
Hoge.java
class Hoge {
public static void main(String... args) {
System.out.println("Hello World");
}
}
When debugging a Java program with Eclipse, add the following spell to the startup options.
> java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y -cp build\classes\java\main Hoge
Prior to Java 9, this allowed you to remotely connect the debugger with the 8000
port (you need to keep the port open, of course).
However, when I try to connect to a JVM started with this option remotely with a debugger in Java 9 or later, the following error occurs.
JDK 9 Release Notes | Notes and Changes
JDWP socket connector accept only local connections by default The JDWP socket connector has been changed to bind to localhost only if no ip address or hostname is specified on the agent command line. A hostname of asterisk (*) may be used to achieve the old behavior which is to bind the JDWP socket connector to all available interfaces; this is not secure and not recommended.
In Java 9, if you don't specify a host, it will automatically be bound to localhost
, and it seems that you can no longer connect remotely.
You can still connect from any remote location by using *
, such as ʻaddress = *: 8000`.
(However, it seems that it is not recommended because it is not good for security [^ 1])
[^ 1]: It's a non-production environment at the time of connecting with the debugger, so I don't think you need to worry about it. e? Do you connect the production with a debugger? Ahh
> java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=*:8000,suspend=y -cp build\classes\java\main Hoge
connected.
--Debug the jvm running on a non-local machine with Eclipse --TIM Labs
Recommended Posts