views:

66

answers:

3

I know how to remote debug a java application on a machine where it already exists, but does anyone know of a solution that can launch from a local workspace (e.g. eclipse), transfer any code in the local classpath to a remote or virtual machine, execute it there and connect a remote debugger, all in one step? I expect some kind of server would need to run on the remote machine to accept class-files and execute them.

I once did something similar with JUnit, transfering local testcases to a remote machine via RMI and executing them there, transferring the results back to my eclipse. Because those testcases are JUnit-tests it was easy to integrate this with the JUnit-launcher and -tools from eclipse, but for debugging the whole application I suspect it to be a bit more complicated.

I would like to ask if there are any solutions for this or if anyone has done this before and would point me in the right direction.

There is something similar for VMWARE Workstation, but I develop on a Mac and it is not avaliable in Fusion.

A: 

I guess you can automate deployment tasks using ant tasks executed within Eclipse.

  1. For a Java application you may copy your compile classes through ftp http://ant.apache.org/manual/OptionalTasks/ftp.html and use a daemon that scan files in a directory and launch them in debug (may be parsing the Manifest of the jar). You may also "package" your Java application as a J2EE application for convenient debugging purposes
  2. For a J2EE application, you may see deploy capabilities of your J2EE server.
snowflake
+1  A: 

It is not stated if you want to debug a test application or something else. I will assume that it is a normal java application. You could just set up a SMB share or an ftp server in the remote virtual machine, and then use an ant task to jar all of your class files and copy them over to the second virtual machine. Because you are using a mac, then you can connect with ssh and launch the java application with the debug flags. Then, it would be a two step-process:

  • Ant script that
    • Packs all compiled code
    • Copies the compiled code (FTP, SCP, SMB, or something of the sort)
    • Connects with ssh and launches the application with debug options. You can use the option to wait for server to wait for an incoming connection.

Then on Eclipse, you would have a remote debugging config that would connect to the remote machine in the specified code.

For doing it in one step, could be done by writing a small Eclipse plug-in that extends the Debug Launcher. You could extend the Remote Debug Launch to perform these custom copy code.

Mario Ortegón
Thank you for your insight, this would be a good start. Yes, I'm talking about a pretty standard (big) java application. Any idea how to access the classpath that eclipse builds internally for a project from within an ant script? Haven't seen anything in the variables that can be used. I'm able to read the .classpath-file of a selected project, but how would I find dependencies / referenced projects etc.? Maybe I should use maven to generate the complete classpath as a file (at compile time) and use this file as a base for what to transfer to the remote machine.
Philipp Paland
A: 

With eclipse remote control you can launch ant scripts and applications within eclipse from a remote host.

Markus Pielmeier