Philipp Paland
Philipp Paland

Reputation: 41

Launching and debugging a Java application on a remote or virtual machine

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, transferring 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.

Upvotes: 4

Views: 1292

Answers (3)

snowflake
snowflake

Reputation: 1714

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/Tasks/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.

Upvotes: 0

Markus Peröbner
Markus Peröbner

Reputation: 883

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

Upvotes: 0

Mario Ortegón
Mario Ortegón

Reputation: 18900

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.

Upvotes: 2

Related Questions