Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How a java program knows if it has been started by eclipse's `debug` not `run`? [duplicate]

Possible Duplicate:
Determine if a java application is in debug mode in Eclipse

I can start a java program in eclipse by run as or debug as.

Is there any way in the java code to check if it was started by run or debug? I want to do something(e.g. reloading resource) when it's in debug mode only.

like image 209
Freewind Avatar asked Jul 10 '26 14:07

Freewind


1 Answers

Is really eclipse who does the magic, by launching the jvm in debug mode which opens a tcp port to attach a debugger so, if you wish to check if you're in debug mode you'd probably want to check if that port is taking connections, at least is one way I can think of.

like image 180
Juan Alberto López Cavallotti Avatar answered Jul 13 '26 19:07

Juan Alberto López Cavallotti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!