Java Execution Tasks

These tasks make it easier to execute Java programs in separate processes.

Java Component

Fixme (openoffice-common2forrest template)
The previous heading is more than one level below the heading before it. To remove this fixme, correct the structuring of your document.

The Java component runs Java Programs. It is an extension of the runshell component, so all attributes associated with that are usable. the exception is the shellCmd attribute, which is rebound to the JVM


Fixme (openoffice-common2forrest template)
The previous heading is more than one level below the heading before it. To remove this fixme, correct the structuring of your document.
classnamename of the class to executeone of this or jar
jarlocation of a JAR file to run. one of this or classname
endorsedDirslist of endorsed directories. These are the only directories that can contain "endorsed JAR files", as defined in Java1.4 and later.Any files that are passed in here are recognised as such, and the directory that contains them marked as endorsed. Duplicate directories are also recognised.
classpathlist of JAR files and directories
syspropertieslist of properties [-D] options as [name,value] tuples[["http.proxy","true"],["http.proxyPort",8080]]no
environmentlist of environment variables [-D] options as [name,value] tuples[["PATH","/lib/path;~/bin"]
jvmargslist of arguments to the JVM["-incGC","-server"]
jvmname of the program to start the JVM. Default is "java".
assertionsassertions on/off flagno, default=false
maxMemorymaximum memory (in MB). Remember to allocate more for 64-bit systems, as the memory increases.


The Java component uses the normal RunShell component to perform its work, but builds up a new command line combing the Java command, the arguments to the JVM, and the arguments to the programs themselves. Classpath setup is another feature of the component.

Java Package Component

This is a helper component, to aid with classpath setup.

Every Java package represents a set of one or more JAR files.

LoadClass Component

The component loads a Java class, and optionally, tries to create an instance using an empty constructor. It forces these classes into the system, so can be used to ensure that classes are available for other programs.

It serves the following purposes

  1. Verifies that classes can be loaded; that the classpath is correct and all needed libraries are present.

  2. Force loads classes into the classpath

  3. Verifies that a class can be instantiated

  4. Forces any static construction logic of a class to take place, so creating singletons and running any static or shared initialisation logic.

Classes will be retained for the duration of the lifecycle

LoadClassSchema extends Schema {

classes extends Vector;

create extends Boolean;

retain extends Boolean;


LoadClass extends Prim {

schema extends LoadClassSchema;

sfClass "";

create false;

retain true;



Fixme (openoffice-common2forrest template)
The previous heading is more than one level below the heading before it. To remove this fixme, correct the structuring of your document.
classnameList of classes to load ["java.lang.String"]Yes; can be empty []
createFlag to indicate whether instances should be created or not.Yes, default=false
retainFlag to indicate whether classes and instances should be retained until the class is terminated.


All properties are retrieved in the sfStart() operation; then each class is loaded using the codebase of the component. After all classes have been loaded, if the create flag is set, then any instances are created.

Unless retain is false, the classes and instances are kept until the component is terminated, otherwise they are discarded immediately. A System.gc() call is made after discarding all references, but this is of course a hint -there is no deterministic way of purging all references inside a JVM.

Library Components

These are currently unsupported, experimental components to retrieve JAR files from the Maven1/Maven2 libraries, such as the library:

As they are unsupported, users are invited to examine the components in libraries.sf, and the implementation classes and examples to determine their use. As they stabilise and get used more, they will become documented.

#include "/org/smartfrog/services/filesystem/components.sf"

#include "/org/smartfrog/services/os/java/components.sf"

#include "/org/smartfrog/services/os/java/library.sf"

sfConfig extends Compound {

sfSyncTerminate true;

library extends Maven2Library {


commons-logging extends JarArtifact {

library LAZY PARENT:library;

project "commons-logging";

version "1.0.4";

sha1 "f029a2aefe2b3e1517573c580f948caac31b1056";

md5 "8a507817b28077e0478add944c64586a";


axis extends JarArtifact {

library LAZY PARENT:library;

project "axis";

artifact "axis";

version "1.1";

sha1 "edd84c96eac48d4167bca4f45e7d36dcf36cf871";


tcpmonitor extends Java {

classname "org.apache.axis.utils.tcpmon";

classpath [

LAZY axis:absolutePath,

LAZY commons-logging:absolutePath];



There are some issues to be aware of when using these components:

Security in the site is known to be inadequate; too many people have access to that site.

If the MD5 or (better), sha1 checksum of the component is declared, then these are verified in the descriptor. This does secure the downloads.

Most JAR files in the central MD5 repository are unsigned; none will not be loaded by SmartFrog's own classloader when running securely.

It can take a while to download files over HTTP. Once they have been downloaded into the local cache (${user.home}/.m2/repository), they will be available for all applications, without more downloads.

The real Apache Maven2 tools treat files with a version -SNAPSHOT specially, with intermittent polls for updates. The SmartFrog components do not. Trying to deploy -SNAPSHOT releases is considers dangerous as they can vary from day to day, making deployment inherently unstable.

The two ways to use this component effectively are:

  1. Have a private repository of JAR files, in which each one is signed by an authority trusted by the SmartFrog runtimes. This is the only way to load classes into a secure classloader.

  2. Use the components to set up the classpath for a Java component. This is what is done in the example above.