how to use dape with junit in java-debug #120
Replies: 13 comments
-
I tried dap-java with dap-mode, and It worked with I'm not good at elisp, Is there a way to copy this feature? |
Beta Was this translation helpful? Give feedback.
-
Hey I am not that familiar with java maybe @MagielBruntink can help out. |
Beta Was this translation helpful? Give feedback.
-
Yes, the feature exists in the eglot-java package (on Melpa). You need to attach Dape with the Java-debug plugin once you executed a test in debug mode. |
Beta Was this translation helpful? Give feedback.
-
Here is my dape config for Java:
|
Beta Was this translation helpful? Give feedback.
-
@MagielBruntink thanks for the quick reply, I tried your config, and I got the error which fails to attach the localhost:8000 |
Beta Was this translation helpful? Give feedback.
-
Are you using eglot-java to launch the JVM in debug mode? By default it should be using port 8000. "Connection refused" could also mean you have a firewall blocking the connection. Try to disable that. |
Beta Was this translation helpful? Give feedback.
-
@MagielBruntink thank you for you help, after several attempts I finally got it worked First call |
Beta Was this translation helpful? Give feedback.
-
@MagielBruntink Hi, I still have a tiny issue here, I wish you can help me out. |
Beta Was this translation helpful? Give feedback.
-
If you launch unit tests using eglot-java it should add that junit console jar in the call to the JVM. |
Beta Was this translation helpful? Give feedback.
-
Let me explain how I am doing,
(defun ,my-eglot-java-run-test-in-debug ()
(interactive)
(eglot-java-run-test t))
Following this steps, It will breaks if I remove the junit console jar. |
Beta Was this translation helpful? Give feedback.
-
This is the function in eglot-java I meant: https://github.com/yveszoundi/eglot-java/blob/492282d653c91b07ec10b30eb8a05cbfdc4017c7/eglot-java.el#L717 Call it with a prefix argument and it will launch the test with the JVM in debug mode. You need to configure the variable eglot-java-junit-platform-console-standalone-jar, first. And the variable for the JDTLS debug plugin jar. After the test was launched need, you can run dape and it will attach to the JVM for debugging. |
Beta Was this translation helpful? Give feedback.
-
Let me explain how I am doing,
(defun ,my-eglot-java-run-test-in-debug ()
(interactive)
(eglot-java-run-test t))
Following this steps, It will breaks if I remove the junit console jar from pom.xml. Do you use the same steps? |
Beta Was this translation helpful? Give feedback.
-
I assume you downloaded the junit console jar and put it somewhere? And configured the variable to point to it? |
Beta Was this translation helpful? Give feedback.
-
Sorry for asking this question here. Since I can't find the solution anywhere. I made the dape works when java class has the static main method . but it breaks when i called dape and use jdtls in a test class. and i got this error message:
Beta Was this translation helpful? Give feedback.
All reactions