# HG changeset patch # User Joshua Sumali # Date 1210181496 14400 # Node ID 07c44f5d2c521539cefd4180309db414175d2f4a # Parent 1f85b520d1050e32ba71752cf6d868342b9728cf 2008-05-07 Joshua Sumali * rt/net/sourceforge/jnlp/Launcher.java: Check main jar for main class in case main class isn't specified in the jnlp file. * rt/net/sourceforge/jnlp/resources/Messages.properties: Add main class error messages. diff -r 1f85b520d105 -r 07c44f5d2c52 ChangeLog --- a/ChangeLog Wed May 07 10:42:42 2008 -0400 +++ b/ChangeLog Wed May 07 13:31:36 2008 -0400 @@ -1,3 +1,10 @@ +2008-05-07 Joshua Sumali + + * rt/net/sourceforge/jnlp/Launcher.java: Check main jar for main class in + case main class isn't specified in the jnlp file. + * rt/net/sourceforge/jnlp/resources/Messages.properties: Add main class + error messages. + 2008-05-07 Joshua Sumali * rt/net/sourceforge/jnlp/cache/ResourceTracker.java: Close URL diff -r 1f85b520d105 -r 07c44f5d2c52 rt/net/sourceforge/jnlp/Launcher.java --- a/rt/net/sourceforge/jnlp/Launcher.java Wed May 07 10:42:42 2008 -0400 +++ b/rt/net/sourceforge/jnlp/Launcher.java Wed May 07 13:31:36 2008 -0400 @@ -21,6 +21,7 @@ import java.awt.Container; import java.io.*; import java.net.*; +import java.util.jar.JarFile; import java.lang.reflect.*; import net.sourceforge.jnlp.cache.*; @@ -317,6 +318,24 @@ app.initialize(); String mainName = file.getApplication().getMainClass(); + + // When the application-desc field is empty, we should take a + // look at the main jar for the main class. + if (mainName == null) { + JARDesc mainJarDesc = file.getResources().getMainJAR(); + File f = CacheUtil.getCacheFile(mainJarDesc.getLocation(), null); + if (f != null) { + JarFile mainJar = new JarFile(f); + mainName = mainJar.getManifest(). + getMainAttributes().getValue("Main-Class"); + } + } + + if (mainName == null) + throw launchError(new LaunchException(file, null, + R("LSFatal"), R("LCClient"), R("LCantDetermineMainClass") , + R("LCantDetermineMainClassInfo"))); + Class mainClass = app.getClassLoader().loadClass(mainName); Method main = mainClass.getDeclaredMethod("main", new Class[] {String[].class} ); diff -r 1f85b520d105 -r 07c44f5d2c52 rt/net/sourceforge/jnlp/resources/Messages.properties --- a/rt/net/sourceforge/jnlp/resources/Messages.properties Wed May 07 10:42:42 2008 -0400 +++ b/rt/net/sourceforge/jnlp/resources/Messages.properties Wed May 07 13:31:36 2008 -0400 @@ -48,6 +48,8 @@ LInitApplicationInfo= LNotLaunchable=Not a launchable JNLP file. LNotLaunchableInfo=File must be a JNLP application, applet, or installer type. +LCantDetermineMainClass=Unknown Main-Class. +LCantDetermineMainClassInfo=Could not determine the main class for this application. JNotApplet=File is not an applet. JNotApplication=File is not an application.