1.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/FXBrwsrLauncher.java Sun Apr 28 21:17:04 2013 +0200
1.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/FXBrwsrLauncher.java Mon Apr 29 09:53:45 2013 +0200
1.3 @@ -19,12 +19,15 @@
1.4
1.5 import org.apidesign.bck2brwsr.launcher.fximpl.FXBrwsr;
1.6 import java.io.IOException;
1.7 +import java.io.InputStream;
1.8 import java.lang.reflect.Method;
1.9 import java.net.URI;
1.10 import java.net.URL;
1.11 import java.net.URLClassLoader;
1.12 +import java.util.Enumeration;
1.13
1.14 import java.util.concurrent.Executors;
1.15 +import java.util.jar.Manifest;
1.16 import java.util.logging.Level;
1.17 import java.util.logging.Logger;
1.18 import javafx.application.Platform;
1.19 @@ -47,7 +50,7 @@
1.20 throw new LinkageError("Can't add jfxrt.jar on the classpath", ex);
1.21 }
1.22 }
1.23 -
1.24 +
1.25 public FXBrwsrLauncher(String ignore) {
1.26 super(null);
1.27 }
1.28 @@ -94,5 +97,33 @@
1.29 super.close();
1.30 Platform.exit();
1.31 }
1.32 +
1.33 + public static void main(String... args) throws IOException {
1.34 + String startPage = null;
1.35 +
1.36 + final ClassLoader cl = FXBrwsrLauncher.class.getClassLoader();
1.37 + startPage = findStartPage(cl, startPage);
1.38 + if (startPage == null) {
1.39 + throw new NullPointerException("Can't find StartPage tag in manifests!");
1.40 + }
1.41 +
1.42 + Launcher.showURL("fxbrwsr", cl, startPage);
1.43 + }
1.44
1.45 + private static String findStartPage(final ClassLoader cl, String startPage) throws IOException {
1.46 + Enumeration<URL> en = cl.getResources("META-INF/MANIFEST.MF");
1.47 + while (en.hasMoreElements()) {
1.48 + URL url = en.nextElement();
1.49 + Manifest mf;
1.50 + try (InputStream is = url.openStream()) {
1.51 + mf = new Manifest(is);
1.52 + }
1.53 + String sp = mf.getMainAttributes().getValue("StartPage");
1.54 + if (sp != null) {
1.55 + startPage = sp;
1.56 + break;
1.57 + }
1.58 + }
1.59 + return startPage;
1.60 + }
1.61 }