W3C home > Mailing lists > Public > www-jigsaw@w3.org > January to February 1999

Re: Jigsaw happiness

From: Christopher William Turner <cwturner@cycom.co.uk>
Date: Wed, 27 Jan 1999 04:51:37 -0500 (EST)
Message-ID: <36AEE020.9ACC2D80@cycom.co.uk>
To: Kenneth Persson <kenneth@veosystems.com>
CC: www-jigsaw@w3.org
The myServlets.jar just needs to be in the classpath when jigsaw starts up.
When you use jigadm to define the servlets, just specify the full class name of
your
servlet in the appropriate attribute.

An alternative method which I use on java 1.2 is to do everything in java. Java
1.2
allows java code to redirect out and err streams, load jars, classes  and
discover and call methods. You could write code to dynamically discover and load
jars. No script files or
constants are involved.

I attach my source code and here is the relevant extract:-
    try {
  URLClassLoader ucl = URLClassLoader.newInstance(a.urls);
  Class c=null;
  try {
      c = ucl.loadClass(a.className);
  } catch(ClassNotFoundException cnfe){
      System.err.println("class "+a.className+" not found in
"+a.urlsAsString());
  }
  if(c==null){
      checkURLs(a.urls);
  } else {
      Class argTypes[] = new Class[1];
      argTypes[0] = args.getClass();
      Method main = c.getDeclaredMethod("main", argTypes);
      PrintStream newErrStream = new PrintStream(new
LoggingStream(System.err,"jaErr.log"));
      System.setErr(newErrStream);
      PrintStream newStdStream = new PrintStream(new
LoggingStream(System.out,"jaStd.log"));
      System.setOut(newStdStream);
      main.invoke(null, newArgsArray);
  }
     } catch(NoSuchMethodException nsme){
  System.err.println("method main(String []) not found in class
"+a.className());
     } catch(InvocationTargetException ite){
  System.err.println("static invocation of main() failed in class
"+a.className());
     } catch(IllegalAccessException iae){
  System.err.println("access denied to main() in class "+a.className());
     }

--
Chris Turner, http://www.cycom.co.uk/






Received on Wednesday, 27 January 1999 05:07:01 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:28 GMT