Jesse Glick

« Mustang agents can... | Main | Pick a target JDK... »
Wednesday Feb 15, 2006

jrunscript in a target VM

Mustang's jrunscript is cool, but it just launches a new VM and runs your script. Sometimes you want to find out what is going on in an existing process, or control it somehow, using JavaScript. Now you can! Download jrunscriptin.jar and run with

java -jar jrunscriptin.jar
(on Mustang) for usage information, quoted here for your convenience:
Usage:
  java -jar jrunscriptin.jar <PID> 
    where <PID> is as in jps
  java -jar jrunscriptin.jar <match> <JavaScript>
    where <match> is some substring of the text after a PID visible in jps -lm
Example using NetBeans IDE (quoting as in Bourne Shell, adapt as needed):
  java -jar jrunscriptin.jar netbeans \
  'Packages.org.openide.awt.StatusDisplayer.getDefault().setStatusText("Hello from abroad!"); \
  java.lang.System.out.println("OK!")'
Requires Mustang (JDK 6) for both this tool and the target VM.
Sources

Comments:

sounds cool - if it has a GUI like JConsole then we can even use it as a dynamic debugging tool~

Posted by Alex Lam on February 18, 2006 at 07:18 AM EST #

I enhanced jrunscriptin. Now rather than taking one expression and running it, it produces a full read-eval-print loop on standard input and standard output. So you can interactively examine the target process.

Revised sources (binary JAR in same place)

Posted by Jesse Glick on February 18, 2006 at 08:45 PM EST #

Great idea indeed - keep up the good work!

Posted by Alex Lam on February 18, 2006 at 08:59 PM EST #

Now hosted on Kenai! http://kenai.com/projects/jrunscriptin

Posted by Jesse Glick on June 10, 2009 at 10:30 AM EDT #

Post a Comment:
  • HTML Syntax: NOT allowed