Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java JVM Eclipse remote debug with a console enabled

When I attach to a running JVM in Eclipse using socket in a JVM machine running on a diffferent host like production environment, is there a way to get the STDOUT/STDERROR output in console too, i.e to have console enabled too ?

like image 410
Damjan Dimitrioski Avatar asked Dec 15 '11 09:12

Damjan Dimitrioski


People also ask

How do I start JVM in debug mode?

Enable JVM DebuggingClick Java > JVM Settings tab. Under Debug Java Settings, select the Enable Debug checkbox. Provide JVM options as necessary by clicking the New button. If you substitute suspend=y, the JVM starts in suspended mode and stays suspended until a debugger attaches to it.

How do I open debug console in Eclipse?

A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead.

How do I remotely debug a Java program?

Go to the eclipse menu and select Run->Debug Configuration; it opens Debug Configuration setup. On the Debug configuration window, create a new “Remote Java Application” configuration. Select the project to be debugged and give it a Name. Select connection type, Socket Attach, or Socket Listen.


2 Answers

Kind of...

I recently set up an ant script to deploy updates to a remote server and then automatically restart it. The restart script was called using putty's plink utility from ant. The restart script stopped the server, then started it in remote debug mode so I could link to it from my local eclipse for testing/debuging. The interesting thing though is that I did not start the server as a background process, so all the standard output was sent back to plink and displayed in the ant output in the eclipse console. I'm not sure how useful this maybe as the output is prefixed with the usual ant details, and the ant task does not finish until you stop the remote server.

Edit: on reflection the whole thing could be achieved far easier by calling plink to start your remote environment by creating an "External Tools" run configuration.

like image 75
user2072238 Avatar answered Oct 23 '22 11:10

user2072238


Not directly AFAIK. Alternatively, you could use Eclipse Logfile Viewer to trail the tomcat log.

like image 34
dimitrisli Avatar answered Oct 23 '22 10:10

dimitrisli