Closed Feng1231 closed 5 hours ago
No easier way.
The traditional way (ie with gdb and vim, or with jdtls) is to first launch the java app with the following args:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
you're instructing java / Gradle to:
server=y
) and wait for a client to connect to remotely debugsuspend=y
) address=5005
)Then on IntelliJ, you must start the remote debugging client, set the port to 5005, and begin
Or you can just press the 🐞 debug icon. Either
static void main
entry pointIf you run Gradle with debugging, you can use nvim with the dap plugin or any client that supports the debugging adaptor protocol to follow along.
And this includes using things like gdb for c debugging or python too.
I realised that typing
/.gradlew run
in the CLI will only run the AB3 gui, but not in debug mode. For instance, when I set a breakpoint at theexecute
method of theListCommand
class, typinglist
in the GUI input will not result in the application stopping at the methodexecute
.
Sorry can I clarify, are you able to stop at breakpoint before doing GUI? (ie you hit breakpoint and programme pauses when the programme was still CLI mode and you typed list in the CLI)
Expected behavior is that debugging is not enabled when you . /gradlew run
.
I feel like I'm misunderstanding something.
Sorry can I clarify, are you able to stop at breakpoint before doing GUI? (ie you hit breakpoint and programme pauses when the programme was still CLI mode and you typed list in the CLI)
Expected behavior is that debugging is not enabled when you
. /gradlew run
.I feel like I'm misunderstanding something.
I didnt try debugging in the CLI version of Duke. The 'CLI' that I was referring to is the terminal in intellij. My bad for being vague 😪.
Anyways, thank you for the very detailed response! I guess I'll stick to clicking the debug icon.
I realised that typing
/.gradlew run
in the CLI will only run the AB3 gui, but not in debug mode. For instance, when I set a breakpoint at theexecute
method of theListCommand
class, typinglist
in the GUI input will not result in the application stopping at the methodexecute
.A workaround to this issue is to go to the
Main.java
file and press the debug icon (or Shift F9) on the top right corner of the IDE. Then, the application will run in debug mode and stop at the breakpoint that I have set.Does anyone have other ways of debugging in gradle? Because
./gradlew --debug
will not launch the application in debug mode.