0

I am in a trouble that is I want to add a breakpoint in my java program in Intellij Idea, however, the program is start from cmd in a batch job.

java -jar XXX.jar

All the libraries path are also set in the batch job to specify the classpath. If I debug the program directly in intellij idea, it said I miss some libraries dependencies, But I can stop the program at the breakpoint I set. If I start program using batch job. The program can successfully run but It won't stop at the breakpoint.

The reason I would to stop the program is that I want to see the details about my database connection, or there is any ways or methods to extract the details of the connection?

Thanks a lot.

Meo
  • 12,020
  • 7
  • 45
  • 52
rascee
  • 3
  • 2
  • 1
    start java in debug mode from the cli, see https://stackoverflow.com/questions/138511/what-are-java-command-line-options-to-set-to-allow-jvm-to-be-remotely-debugged –  Oct 29 '17 at 07:46
  • Thank for your reply. But I just simply build a program, not a java web application. In the article, it said I can add a debug port in the command to achieve remote debug. So I am wondering what is the debug port of a simple java program? – rascee Oct 29 '17 at 11:27
  • This sounds really hard. You can connect a remote debugger, but your app would have to actually be running for that to work, and I'm not sure if you have a persistent process to connect to. You're probably better off just putting some debug statements in there to output the values you want to a log. You can change the logging level to make them go away again. Of course, this means being able to access the logs. – Software Engineer Oct 29 '17 at 12:34
  • 1
    Remote debugging is not web app specific, any java process can be debugged this way (you need the source code and the special flags to run it in debug mode). And the port is the one you define with the flags –  Oct 29 '17 at 12:52
  • Thank you so much, It works for me! – rascee Nov 01 '17 at 07:43

0 Answers0