Class Viewer


  • public class Viewer
    extends java.lang.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:

    % java javassist.tools.web.Viewer host port Main arg1, ...

    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:

     Viewer v = (Viewer)this.getClass().getClassLoader();
     String port = v.getPort();
     
    • Constructor Summary

      Constructors 
      Constructor Description
      Viewer​(java.lang.String host, int p)
      Constructs a viewer.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getPort()
      Returns the port number.
      java.lang.String getServer()
      Returns the server name.
      static void main​(java.lang.String[] args)
      Starts a program.
      void run​(java.lang.String classname, java.lang.String[] args)
      Invokes main() in the class specified by classname.
      • Methods inherited from class java.lang.ClassLoader

        clearAssertionStatus, getDefinedPackage, getDefinedPackages, getName, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Viewer

        public Viewer​(java.lang.String host,
                      int p)
        Constructs a viewer.
        Parameters:
        host - server name
        p - port number
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Throwable
        Starts a program.
        Throws:
        java.lang.Throwable
      • getServer

        public java.lang.String getServer()
        Returns the server name.
      • getPort

        public int getPort()
        Returns the port number.
      • run

        public void run​(java.lang.String classname,
                        java.lang.String[] args)
                 throws java.lang.Throwable
        Invokes main() in the class specified by classname.
        Parameters:
        classname - executed class
        args - the arguments passed to main().
        Throws:
        java.lang.Throwable