From d9a462f1ece1230564eba6baf2ada2c0b2ec03ff Mon Sep 17 00:00:00 2001 From: hns Date: Mon, 2 Dec 2002 13:26:01 +0000 Subject: [PATCH] Do not mess with HOP_HOME in launcher/Main --- src/helma/main/Server.java | 9 +++++- src/helma/main/launcher/Main.java | 47 ++++++++++++------------------- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/helma/main/Server.java b/src/helma/main/Server.java index 559eb945..602b59cf 100644 --- a/src/helma/main/Server.java +++ b/src/helma/main/Server.java @@ -222,8 +222,15 @@ import org.apache.xmlrpc.*; } catch (IOException iox) { System.err.println ("Error calling getCanonicalFile() on hopHome: "+iox); } + + // set the current working directory to the helma home dir. + // note that this is not a real cwd, which is not supported + // by java. It makes sure relative to absolute path name + // conversion is done right, so for Helma code, this should + // work. + System.setProperty ("user.dir", hopHome.getPath()); - // from now on it's safe to call getLogger() + // from now on it's safe to call getLogger() because hopHome is set up String startMessage = "Starting Helma "+version+ " on Java "+System.getProperty ("java.version"); diff --git a/src/helma/main/launcher/Main.java b/src/helma/main/launcher/Main.java index d46d2837..ccd1f76e 100644 --- a/src/helma/main/launcher/Main.java +++ b/src/helma/main/launcher/Main.java @@ -27,49 +27,38 @@ public class Main { // check if home directory is set via command line arg. If not, // we'll get it from the location of the jar file this class // has been loaded from. - String home = null; + String installDir = null; // first, try to get helma home dir from command line options for (int i=0; i!/{entry} // we strip away the jar: prefix and the !/{entry} suffix // to get the original jar file URL - home = homeUrl.toString().substring(4); - int excl = home.indexOf ("!"); + installDir = launcherUrl.toString().substring(4); + int excl = installDir.indexOf ("!"); if (excl > -1) { - home = home.substring(0, excl); - homeUrl = new URL (home); - File f = new File (homeUrl.getPath()); - home = f.getParent(); - // add home dir to the command line arguments - String[] newArgs = new String [args.length+2]; - newArgs[0] = "-h"; - newArgs[1] = home; - System.arraycopy (args, 0, newArgs, 2, args.length); - args = newArgs; + installDir = installDir.substring(0, excl); + launcherUrl = new URL (installDir); + File f = new File (launcherUrl.getPath()); + installDir = f.getParentFile().getCanonicalPath(); } - } catch (Exception ignore) { - // unable to get Helma home dir from launcher jar + } catch (Exception x) { + // unable to get Helma installation dir from launcher jar + System.err.println ("Unable to get Helma installation directory: "+x); } } - // set the current working directory to the helma home dir. - // note that this is not a real cwd, which is not supported - // by java. It makes sure relative to absolute path name - // conversion is done right, so for Helma code, this should - // work. - System.setProperty ("user.dir", home); // set up the class path - File libdir = new File (home, "lib"); + File libdir = new File (installDir, "lib"); ArrayList jarlist = new ArrayList (); for (int i=0;i