dansomething / coc-java-debug

An extension for coc.nvim to enable Java debugging via jdt.ls
https://www.npmjs.com/package/coc-java-debug
Eclipse Public License 2.0
102 stars 8 forks source link

How start a java process with debug enabled? #1

Closed LinArcX closed 4 years ago

LinArcX commented 4 years ago

Hi. first of all, let me thank you for this plugin. I tired to debug a super simple java application that contains only one file: main.java:

public class main {
    public static void main(String[] args) {
        System.out.println("foo");
        System.out.println("bar");
    }
}

So, i don't use maven or other fancy stuff. Seems in README we need maven to start a java process. Is it necessary?

First, run a Java process with debug enabled. Make sure its configured to pause and wait for a remote debugger on port 5005. For example: mvn test -Dmaven.surefire.debug

dansomething commented 4 years ago

Maven is not required. That is just an example using it. As long as you enable the remote debugger of a Java process you should be able to connect to it. For your example of a single java file named "main", it should work like this to start the java process with the debug server enabled on port 5005.

javac main.java
java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=5005,suspend=y main

A quick search on Google for "java remote debugging" should reveal a lot of other examples.

LinArcX commented 4 years ago

Yeah, it works. Thank you.

dansomething commented 4 years ago

I added this plain Java example to the readme.