All Packages Class Hierarchy This Package Previous Next Index
![]() |
java.lang.Object | +----Acme.Application
Make all your applications a subclass of this, and you can more easily embed them in larger applications or applets. What it does is define an enhanced main routine that gives you three standard I/O streams to use instead of System.in, System.out, and System.err.
When run from the command line there's no difference between the enhanced main and the regular one - you get the System streams. The point of this class is that you can also run your applications from applets, from other applications, in pipelines, and in contexts yet to be invented, and then you get passed other streams appropriate to those contexts.
There are a few simple steps to converting your application to use this class.
public class YourApp extends Acme.Application
Note that the enhanced newMain() is *not* static. It must be an instance method so that it can be called at runtime - Java has no way to call a static method of a runtime-loaded class.public int newMain( String[] args )
public static void main( String[] args )
{
(new YourApp()).compat( args );
}
This lets you continue to run your application from the command line.
But be sure and leave the old-style main() static.
Fetch the software.
Fetch the entire Acme package.
For an example of a non-command-line context that can call these enhanced Applications,
protected InputStream in
protected PrintStream out
protected PrintStream err
public Application()
public void compat(String args[])
public int compat(String args[],
InputStream stdin,
PrintStream stdout,
PrintStream stderr)
public abstract int newMain(String args[])
All Packages Class Hierarchy This Package Previous Next Index
ACME Java ACME Labs