javassist.tools.web

Class Viewer

public class Viewer extends ClassLoader

A sample applet viewer.

This is a sort of applet viewer that can run any program even if the main class is not a subclass of Applet. This viewwer first calls main() in the main class.

To run, you should type:

This command calls Main.main() with arg1,... All classes including Main are fetched from a server http://host:port. Only the class file for Viewer must exist on a local file system at the client side; even other javassist.* classes are not needed at the client side. Viewer uses only Java core API classes.

Note: since a Viewer object is a class loader, a program loaded by this object can call a method in Viewer. For example, you can write something like this:

Constructor Summary
Viewer(String host, int p)
Constructs a viewer.
Method Summary
intgetPort()
Returns the port number.
StringgetServer()
Returns the server name.
static voidmain(String[] args)
Starts a program.
voidrun(String classname, String[] args)
Invokes main() in the class specified by classname.

Constructor Detail

Viewer

public Viewer(String host, int p)
Constructs a viewer.

Parameters: host server name p port number

Method Detail

getPort

public int getPort()
Returns the port number.

getServer

public String getServer()
Returns the server name.

main

public static void main(String[] args)
Starts a program.

run

public void run(String classname, String[] args)
Invokes main() in the class specified by classname.

Parameters: classname executed class args the arguments passed to main().

Javassist, a Java-bytecode translator toolkit.
Copyright (C) 1999-2006 Shigeru Chiba. All Rights Reserved.