Differences between revisions 1 and 5 (spanning 4 versions)
Revision 1 as of 2005-03-01 21:33:31
Size: 4009
Editor: ClarkUpdike
Comment:
Revision 5 as of 2014-04-30 04:30:00
Size: 4011
Editor: AdamBurke
Comment:
Deletions are marked like this. Additions are marked like this.
Line 17: Line 17:
[#commandlinesnarf Eclipse hint: external java command "snarfing" tip] [[#commandlinesnarf|Eclipse hint: external java command "snarfing" tip]]
Line 19: Line 19:
And here's what the optiona mean: And here's what the options mean:
Line 47: Line 47:
For Net``Beans: [[BR]] For Net``Beans: <<BR>>
Line 58: Line 58:
[[Anchor(commandlinesnarf)]] <<Anchor(commandlinesnarf)>>

The following describes how to set up a remote debugging session with a running jython application (or any java application for that matter).

Basically, you just:

  • Modify the java command line that starts jython
  • Set up your ide to attach to the debugging session

Java Command Line To Startup The App

Here's what mine looks like to run from the jar:

C:\apps\j2sdk1.4.2\jre\bin\java.exe -Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000 -Dpython.home=C:\\workspace\\JythonTip\\jython\\dist -jar c:\workspace\JythonTip\jython\dist\jython.jar

or to run from the class directories:

C:\apps\j2sdk1.4.2\jre\bin\java.exe -Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000 -classpath <very long classpath> org.python.util.jython

Eclipse hint: external java command "snarfing" tip

And here's what the options mean:

Command Line Option

Meaning

-Xnoagent

Disables the old sun.tools.debug agent

-Djava.compiler=NONE

Turn off JIT compilation (required in order to use the "classic" debugger)

-XDebug

Enable debugging

-Xrunjdwp:<options>

Enable the Java Debug Wire Protocol

And here's the <options>:

JDWP Option

Meaning

server=y

Tell the app to listen for debugging connections

transport=dt_socket

We're going to use a socket (see below for other options)

address=8000

The socket to listen on

Note: Once you hit enter, the app may not respond like it normally does. For the jython interpreter, it seems to "hang". But once you attach your debugger to it (below), it will respond with the familiar propmt--kind of like "lazy initialization".

See below for further references...

IDE Settings

For Eclipse:

  • Navigate into your source and set your break points.
  • Select Run|Debug.

  • Look for the Remote Java Application run configuration type on the Debug dialog.

  • Select your jython project.
  • The Connection Type: should be Standard(Socket Attach). I imagine in the future there may be other options, like shared memory (if your running locally on windows).

  • Enter 8000 for the port number (or whatever port number you configure your app to listen on).

  • Click Debug

This will take you into the app at the first breakpoint.

For NetBeans:
[^http://debuggercore.netbeans.org/docs/VM-options.html netbeans vm options for debugging]

I have used this technique also for debugging a development Tomcat server remotely (see article below). Keep in mind that in a multithreaded environment, all threads will get stopped at your breakpoint, so be warned if this is not a private workspace.

References


Eclipse External Command "Snarfing" Tip

If you have an app that you run inside eclipse and you want to run it standalone (in a shell), you can get at the launch command that Eclipse uses:

  • Go into the Eclipse debug perspective.
  • If you don't already have a debug session showing for the app (live or terminated), start it up.
  • Click on the + to expand the debug session (if needed).

  • You should see a line like this:
    • <path to javaw.exe>\javaw.exe (<timestamp>)

    • Mine is: C:\apps\j2sdk1.4.2\jre\bin\javaw.exe (Mar 1, 2005 4:24:02 PM)

  • Right-click on this line and select properties.
  • You can then swipe/copy the Command Line info.

  • You can then paste this into your shell. You'll typically want to convert the javaw.exe to a java.exe to receive output to the shell.

ClarkUpdike/RemoteJythonDebugging (last edited 2014-04-30 04:30:00 by AdamBurke)