Do not mess with HOP_HOME in launcher/Main
This commit is contained in:
parent
9fa5abf0ac
commit
d9a462f1ec
2 changed files with 26 additions and 30 deletions
|
@ -223,7 +223,14 @@ import org.apache.xmlrpc.*;
|
|||
System.err.println ("Error calling getCanonicalFile() on hopHome: "+iox);
|
||||
}
|
||||
|
||||
// from now on it's safe to call getLogger()
|
||||
// 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() because hopHome is set up
|
||||
|
||||
String startMessage = "Starting Helma "+version+
|
||||
" on Java "+System.getProperty ("java.version");
|
||||
|
|
|
@ -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<args.length; i++) {
|
||||
if (args[i].equals ("-h") && i+1<args.length) {
|
||||
home = args[i+1];
|
||||
if (args[i].equals ("-i") && i+1<args.length) {
|
||||
installDir = args[i+1];
|
||||
}
|
||||
}
|
||||
URLClassLoader apploader = (URLClassLoader) ClassLoader.getSystemClassLoader();
|
||||
// try to get Helma installation directory
|
||||
if (home == null) {
|
||||
if (installDir == null) {
|
||||
try {
|
||||
URL homeUrl = apploader.findResource("helma/main/launcher/Main.class");
|
||||
URL launcherUrl = apploader.findResource("helma/main/launcher/Main.class");
|
||||
// this is a JAR URL of the form
|
||||
// jar:<url>!/{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<jars.length;i++) {
|
||||
File jar = new File (libdir, jars[i]);
|
||||
|
|
Loading…
Add table
Reference in a new issue