- /** common entry point */
- public static void main(String[] args) {
- try {
- int startargs = 0;
- while (true) {
- if (startargs > args.length - 1) {
- System.out.println("Usage: xwt [-s] [-v] source-location [initial-template]");
- System.out.println("");
- System.out.println("Options:");
- System.out.println(" -s show rendering activity with red rectangles");
- System.out.println(" -v verbose logging");
- System.out.println("");
- System.out.println("Source-location is one of the following:");
- System.out.println(" - the path to an xwar file");
- System.out.println(" - the path to a directory to be used as an xwar");
- System.out.println(" - the http url of an xwar");
- System.out.println("");
- System.out.println("Initial-template is the resource name of the template to load; defaults to 'main'");
- Runtime.getRuntime().exit(-1);
- }
- else if (args[startargs].equals("-s")) showRenders = true;
- else if (args[startargs].equals("-v")) Log.verbose = true;
- else break;
- startargs++;
- }
- final String instancename = args.length > startargs + 1 ? args[startargs + 1] : "main";
-
- Platform.forceLoad();
- if (Log.on) for(int i=0; i<args.length; i++) Log.log(Main.class, "argument " + i + ": " + args[i]);
-
- // we do this here instead of in a static initializer to avoid threading hazards
- if (Log.on) Log.log(Main.class, "loading scar image");
- PNG png = PNG.decode(new ByteArrayInputStream(Base64.decode(scarPicture_png_base64)), "bundled scar image");
- Surface.scarPicture = Platform.createPicture(png.getData(), png.getWidth(), png.getHeight());
-
- InputStream is = Main.class.getClassLoader().getResourceAsStream("org/xwt/builtin.xwar");
- if (is == null) Platform.criticalAbort("unable to load builtin.xwar");
- Resources.loadArchive(is);
-
- String initialTemplate = "main";
-
- if (args.length > startargs) {
- if (args[startargs].startsWith("http://")) {
- if (Log.on) Log.log(Main.class, "downloading xwar");
- origin = args[startargs];
- initialTemplate = "org.xwt.builtin.splash";
-
- } else {
- if (Log.on) Log.log(Main.class, "loading xwar from local filesystem");