Echidna - A free multiprocess system in Java

What's new?

June-2001:

Back in business.

I've imported the Echidna sources into Sourceforge. This development code includes new features (JDK1.3 compatibility, JARs in classpaths, some complex code rewritten to be understandable). See the SourceForge project page for details.

What it is.

Echidna is a class library which, with a reasonable degree of transparency, allows multiple 'processes' to run inside a single Virtual Machine. Implemented entirely in Java, it allows all your objects to live inside a single virtual machine, rather than spawning off a separate VM for each 'application'. The result is a much smaller memory-footprint and much faster startup-times for your code. These advantages make it a powerful tool for such common tasks as:

  • Compiling files with javac.
  • Generating documentation with polardoc.
  • Publishing RMI objects.
  • Quickly testing new revisions of code.
Notable features include:
  • Ability to have large 'stable' classes (like the core api, Swing and JGL) stay in the system's primordial namespace while loading and reloading development classes into the system seamlessly.
  • Ability to determine which process is currently executing, to create lightweight namespaces giving each process its own traditionally static-shared resources like standard io streams.
  • Resource-registration allowing processes to cleanly dispose of important resources when they are killed. For example, when a process is killed all its Windows are automatically removed.
  • Extended Classpath capabilities to allow classes to be transparently loaded from any URL you have a protocol-handler for.
  • Per-process classpaths, so each process can load classes from any source, regardless of normal classpath and the classpaths of other processes.
  • Ease of use. The API is very easy to use, you could compile a file as easily as ProcessManagerHolder.getProcessManager().createProcessFromString('sun.tools.javac.Main foo.java').launch().
I've now added screenshots of the Echidna process manager in action! You can either see a whole lot of Java programs running in the same JVM (using a less than 3mb of ram combined after the first process is created - not much ram for 7 serious programs and a daemon!), or some really geeky wallpaper.

Getting started.

ProcessManager. The most fun thing to start with is the ProcessManager. To run it:

  1. Place lib/echidna_core.jar and lib/echidna_processmanager/ in your CLASSPATH.
  2. Run java org.javagroup.tools.processmanager.Main.

That will pop up the GUIpictured at the top of this page from which you can run processes.

ProcessService. Another good way to run Echidna processes is from a command-line. Echidna includes a small daemon to listen on a port and take process requests.

  1. Run java org.javagroup.misc.ProcessService.
  2. Connect to port 7080 of your machine and type a classname follow by some arguments for it to run, eg 'sun.tools.javac.Main -d /home/luke/classes /home/luke/src/Foo.java'.

You can connect to port 7080 with telnet or an easier way is to use 'netcat' (a linux binary is provided here as a convenience) with the following script called 'ejava':

#!/bin/sh
echo $*|nc localhost 7080

Then in my shell, I run 'ejava sun.tools.javac.Main' to invoke the compiler, etc.

Also, you can start ProcessService without the GUI and later bring up the GUI with 'ejava org.javagroup.tools.processmanager.Main'

CLASSPATH. It's a good idea (particularly for GUI programs) to leave them out of your CLASSPATH and instead put them in Echidna's own enhanced classpath.

You can set the Echidna classpath for the classes of all processes by setting the system property default.classpath with a comma-delimited list of URLs to search for classes, e.g.:

java 	-Ddefault.classpath=/home/luke/classes/,http://mysite.com/me/classes/	org.javagroup.tools.processmanager.Main

NB: because these are proper URLs, the trailing '/' is significant in paths, and even underWindows '/' should be used rather than ''.

Any libraries in the main classpath (CLASSPATH) are still shared by all applications, so if you put Swing, etc. there you don't waste memory loading these libraries for each process.

ProcessService has an '-eclasspath' optional parameter which lets you specify a classpath of the same form used in the -Ddefault.classpath. This makes it easier if you forgot to add all your paths to the system property and want to launch things with ProcessService. Example:

ejava -eclasspath http://mycodeserver/classes/ MyApp

Using Echidna's enhanced classpath accomplishes several things:

  • Allows the classes to be loaded from arbitrary URLs.
  • Allows classes to be (re)loaded fresh each time you launch the process so you can reload new versions of development code into yourJVM after modifying them.
  • Allows different versions of the same program to run simultaneously in separate Echidna processes.
  • Lets Echidna use its ClassLoader information to better track who's doing what.
  • Prevents 'collisions' between classes loaded by the default class loader (from the path in CLASSPATH) and classes loaded by Echidna's custom class loader (from the path in default.classpath and/or -eclasspath).

Changes since alpha-3.

Echidna 0.4.0 drops the 'alpha' status, since Echidna has now been working well for me for over a year. This latest released includes several bugfixes and small enhancements:
  • Package name changed from 'ORG.javagroup' to 'org.javagroup'.
  • Added support of '-eclasspath' parameter in ProcessManager.createProcessFromString. This makes it easier to use per-process classpaths without special tools.
  • Ability to launch programs with package-visible 'main' classes by modifying bytecodes in the classloader. Thanks to Shawn Silverman for this patch.
  • Added support for checking the state of a process (unstarted, running, finished) and waiting for process completion.
  • The GUI Process Manager has been upgraded to work with 'java' Swing 1.1.
  • Documentation - A small Users' Guide is available for Echidna now!
See the ChangeLog for more details.

Known bugs and limitations.

Lack of JAR support.

Echidna tracks processes through their ThreadGroups and ClassLoaders, though this is transparent to the programmer. Known limitations are:

  • Fails to determine the current process if threads not spawned by the process make calls from classes not loaded by the process' class loader -- typically, AWT threads running classes loaded by the primordial classloader. Usually the process's classloader will be on the stack and this will not cause a problem.
  • Requires a SecurityManager, which is a valuable resource in a JVM. This will prevent other applications requiring SecurityManagers to work inside a VM running Echidna. A superset of the security api is what is needed here. The Core API provides all the primitives to create a flexible system, but is not a flexible system in itself. More on this later.

Future.

Echidna is a piece of a larger plan to get more out of JVMs. For more information about the larger picture, see the Java Desktop page.

Immediate future changes for 0.4.1 are:

  • Implement JProcess.getExitCode()
  • Create scripts for launching standard programs
  • Clean up this webpage.

How you can help.

Any feedback, suggestions and bug reports would be greatly appreciated. Also anything you write using Echidna would make a valuable contribution - either as a useful tool to share with other programmers or as an example of how to program with Echidna. Also, if you make any useful changes or enhancements to Echidna I'd like to fold them into it, so please mail them in.

Getting Echidna.

You can download Echidna and its documentation here, either as a gzip'd tar file or a zip-file. Echidna is freely available, with source, under the terms of the GNU Library General Public License. See 'COPYING.LIB' in the distribution for more information.

New! The Echidna User Manual is now available, which gives anoverview of using Echidna. The manual is available in PDF and PostScript.

Related programs and projects.

I'm going to keep a list of useful programs that run happily in Echidna as I become aware of them. The ones I'm currently using are:
  • IBM Jikes! Debugger
  • IBM IRC Client for Java
  • Jacob Java project manager and class browser with Emacs integration.
  • JFAAppLauncher:An excellent application-launching toolbar being developed with support for Echidna.
There have to be more useful Java programs out there, but I haven't had time to track them down. If you have a favorite, please mail me a URL so I can add it to the list.
Also, Mike Hardy is working on a tcsh-like Java shell using Echidna for job control. You can see the latest on it at his Java-shell homepage.

Contact.

To get in touch with me, drop me. If appropriate, I'll create a FAQ for Echidna, for now please contact me directly with anything relating to using Echdina.

You can also join the mailing list discussions by sending a mail with subscribe echidna-interest as the body to majordomo@vegetable.org.

Credits.

Echidna was developed by Luke Gorrie, with a significant portion of Alpha-3 coming from Kirill Bogdanov. Patches and suggestions from members of the mailing list have also been an invaluable help.

There's some thanks due, some of it is:

  • KB Sriram for Installshield Java Edition.
  • Jamie Cansdale for many discussions about brutal hacks to VMs to make multiprocess things work.
  • Darius Bacon for writing most of the 'Teeny' scheme-like language which will prove very useful to Echidna.
  • RickRoss for providing time and resources for Echidna development.
  • Jonathan Porter, who has made some good suggestions which will be implemented inEchidna in the future.
Thanks for reading.