/*
 * ExecJar.java
 * Execute a Jar file.
 *  This is a Java wrapper which is executed as an application.  The first
 *  argument is the JAR file to actually execute, the rest are parameters.
 *
 * Copyright (c) 1998
 *      Transvirtual Technologies, Inc.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file.
 */

package kaffe.jar;

import java.io.IOException;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;

public class ExecJar {

public static void main(String[] args)
{
	// Get JAR file
	JarFile jar = ExecJarName.getJar(args[0]);

	// Look for manifest
	Manifest manifest = null;
	try {
		manifest = jar.getManifest();
		if (manifest == null) {
			System.err.println("No manifest found in ``"
			    + args[0] + "''");
			System.exit(1);
		}
	} catch (IOException e) {
		System.err.println("Can't access manifest in ``"
		    + args[0] + "'': " + e);
		System.exit(1);
	}

	// Get "Main-Class" attribute
	String mainClass = manifest.getMainAttributes().getValue(
					Attributes.Name.MAIN_CLASS);
	if (mainClass == null) {
		System.err.println("No ``Main-Class'' found in manifest");
		System.exit(1);
	}

	// Now call ExecJarName's main()
	String[] newArgs = new String[args.length + 1];
	System.arraycopy(args, 1, newArgs, 2, args.length - 1);
	newArgs[0] = args[0];
	newArgs[1] = mainClass.replace('/', '.');
	ExecJarName.main(newArgs);
}

}


@@ -421,16 +421,50 @@
 eption;%0A
+import java.util.StringTokenizer;%0A
 import j
@@ -548,16 +548,51 @@
 anifest;
+%0Aimport kaffe.management.Classpath;
 %0A%0Apublic
@@ -1283,24 +1283,378 @@
 xit(1);%0A%09%7D%0A%0A
+%09// Add ourselves to the classpath%0A%09Classpath.add(jar.getName());%0A%0A%09// Get %22Class-Path%22 attribute%0A%09String classPath = manifest.getMainAttributes().getValue(%0A%09%09%09%09%09Attributes.Name.CLASS_PATH);%0A%09if (classPath != null) %7B%0A%09    StringTokenizer st = new StringTokenizer(classPath);%0A%09    while(st.hasMoreElements()) %7B%0A%09%09Classpath.add(st.nextToken());%0A%09    %7D%0A%09%7D%0A%0A
 %09// Now call

handle Class-Path Attribute