// main directory. There should be only one, and it's manifest
// Main-Class attribute is the main class. The JarClassLoader will take
// care of finding it.
InputStream is = Boot.class.getResourceAsStream("/" + mainJar);
if (is != null) {
JarInputStream jis = new JarInputStream(is);
Manifest mainmanifest = jis.getManifest();
jis.close();
mainClass = mainmanifest.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS);
} else {
// There is no main jar. Info unless mainJar is empty string.
// The load(mainClass) will scan for main jars anyway.
if (!"".equals(mainJar)){
LOGGER.info("Unable to locate main jar '" + mainJar + "' in the JAR file " + getMyJarPath());
}
}
}
// Do we need to create a wrapping classloader? Check for the
// presence of a "wrap" directory at the top of the jar file.
URL url = Boot.class.getResource(WRAP_JAR);
if (url != null) {
// Wrap class loaders.
final JarClassLoader bootLoader = getBootLoader(bootLoaderName);
bootLoader.load(null);
// Read the "Wrap-Class-Loader" property from the wraploader jar file.
// This is the class to use as a wrapping class-loader.
InputStream is = Boot.class.getResourceAsStream(WRAP_JAR);
if (is != null) {
JarInputStream jis = new JarInputStream(is);
final String wrapLoader = jis.getManifest().getMainAttributes().getValue(WRAP_CLASS_LOADER);
jis.close();
if (wrapLoader == null) {
LOGGER.warning(url + " did not contain a " + WRAP_CLASS_LOADER + " attribute, unable to load wrapping classloader");
} else {
LOGGER.info("using " + wrapLoader);
JarClassLoader wrapped = getWrapLoader(bootLoader, wrapLoader);