Re: Jigsaw happiness

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 UTC