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
|
@ -222,8 +222,15 @@ import org.apache.xmlrpc.*;
|
||||||
} catch (IOException iox) {
|
} catch (IOException iox) {
|
||||||
System.err.println ("Error calling getCanonicalFile() on hopHome: "+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+
|
String startMessage = "Starting Helma "+version+
|
||||||
" on Java "+System.getProperty ("java.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,
|
// 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
|
// we'll get it from the location of the jar file this class
|
||||||
// has been loaded from.
|
// has been loaded from.
|
||||||
String home = null;
|
String installDir = null;
|
||||||
// first, try to get helma home dir from command line options
|
// first, try to get helma home dir from command line options
|
||||||
for (int i=0; i<args.length; i++) {
|
for (int i=0; i<args.length; i++) {
|
||||||
if (args[i].equals ("-h") && i+1<args.length) {
|
if (args[i].equals ("-i") && i+1<args.length) {
|
||||||
home = args[i+1];
|
installDir = args[i+1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
URLClassLoader apploader = (URLClassLoader) ClassLoader.getSystemClassLoader();
|
URLClassLoader apploader = (URLClassLoader) ClassLoader.getSystemClassLoader();
|
||||||
// try to get Helma installation directory
|
// try to get Helma installation directory
|
||||||
if (home == null) {
|
if (installDir == null) {
|
||||||
try {
|
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
|
// this is a JAR URL of the form
|
||||||
// jar:<url>!/{entry}
|
// jar:<url>!/{entry}
|
||||||
// we strip away the jar: prefix and the !/{entry} suffix
|
// we strip away the jar: prefix and the !/{entry} suffix
|
||||||
// to get the original jar file URL
|
// to get the original jar file URL
|
||||||
home = homeUrl.toString().substring(4);
|
installDir = launcherUrl.toString().substring(4);
|
||||||
int excl = home.indexOf ("!");
|
int excl = installDir.indexOf ("!");
|
||||||
if (excl > -1) {
|
if (excl > -1) {
|
||||||
home = home.substring(0, excl);
|
installDir = installDir.substring(0, excl);
|
||||||
homeUrl = new URL (home);
|
launcherUrl = new URL (installDir);
|
||||||
File f = new File (homeUrl.getPath());
|
File f = new File (launcherUrl.getPath());
|
||||||
home = f.getParent();
|
installDir = f.getParentFile().getCanonicalPath();
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
} catch (Exception ignore) {
|
} catch (Exception x) {
|
||||||
// unable to get Helma home dir from launcher jar
|
// 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
|
// set up the class path
|
||||||
File libdir = new File (home, "lib");
|
File libdir = new File (installDir, "lib");
|
||||||
ArrayList jarlist = new ArrayList ();
|
ArrayList jarlist = new ArrayList ();
|
||||||
for (int i=0;i<jars.length;i++) {
|
for (int i=0;i<jars.length;i++) {
|
||||||
File jar = new File (libdir, jars[i]);
|
File jar = new File (libdir, jars[i]);
|
||||||
|
@ -85,9 +74,9 @@ public class Main {
|
||||||
if (files != null)
|
if (files != null)
|
||||||
for (int i=0;i<files.length; i++)
|
for (int i=0;i<files.length; i++)
|
||||||
// WORKAROUND: add the files in lib/ext before
|
// WORKAROUND: add the files in lib/ext before
|
||||||
// lib/apache-dom.jar, since otherwise putting a full version
|
// lib/apache-dom.jar, since otherwise putting a full version
|
||||||
// of Xerces in lib/ext would cause a version conflict with the
|
// of Xerces in lib/ext would cause a version conflict with the
|
||||||
// xerces classes in lib/apache-dom.jar. Generally, having some pieces
|
// xerces classes in lib/apache-dom.jar. Generally, having some pieces
|
||||||
// of Xerces in lib/apache-dom.jar is kind of problematic.
|
// of Xerces in lib/apache-dom.jar is kind of problematic.
|
||||||
jarlist.add (jars.length-3, new URL ("file:" + files[i].getAbsolutePath()));
|
jarlist.add (jars.length-3, new URL ("file:" + files[i].getAbsolutePath()));
|
||||||
URL[] urls = new URL[jarlist.size()];
|
URL[] urls = new URL[jarlist.size()];
|
||||||
|
|
Loading…
Add table
Reference in a new issue