diff --git a/src/helma/main/launcher/Main.java b/src/helma/main/launcher/Main.java new file mode 100644 index 00000000..96abb1fc --- /dev/null +++ b/src/helma/main/launcher/Main.java @@ -0,0 +1,58 @@ +// helma.main.Main + +package helma.main.launcher; + +import java.net.URLClassLoader; +import java.net.URL; +import java.io.File; +import java.io.FilenameFilter; +import java.lang.reflect.Method; + +/** + * Helma bootstrap class. Figures out Helma home directory, sets up class path and + * lauchnes main class. + */ +public class Main { + + + public static void main (String[] args) throws Exception { + + // try to get Helma installation directory + try { + URLClassLoader apploader = (URLClassLoader) Main.class.getClassLoader(); + // (URLClassLoader) Thread.currentThread().getContextClassLoader(); + URL homeUrl = apploader.findResource("helma/main/launcher/Main.class"); + String home = homeUrl.toString().substring(4); + int excl = home.indexOf ("!"); + if (excl > -1) { + home = home.substring(0, excl); + homeUrl = new URL (home); + File f = new File (homeUrl.getPath()); + f = f.getParentFile(); + System.err.println ("GOT HOME: "+f); + } + } catch (Exception ignore) { + // unable to get Helma home dir from launcher jar + } + File libdir = new File ("lib"); + File[] files = libdir.listFiles (new FilenameFilter() { + public boolean accept (File dir, String name) { + if (name.startsWith ("helma")) + return "helma.jar".equals (name); + return name.endsWith (".jar"); + } + }); + URL[] urls = new URL[files.length]; + for (int i=0; i