1 25 package org.snipsnap.server; 26 27 import java.io.File ; 28 import java.io.FileOutputStream ; 29 import java.io.IOException ; 30 import java.io.PrintStream ; 31 32 39 public class SnipSnapLauncher extends Launcher { 40 41 46 public static void main(String [] args) { 47 File toolsJar = new File (new File (System.getProperty("java.home")), "lib/tools.jar"); 49 if (!toolsJar.exists()) { 50 toolsJar = new File (new File (System.getProperty("java.home")), "../lib/tools.jar"); 51 } 52 if (!toolsJar.exists()) { 53 String system = System.getProperty("os.name"); 54 if (system.startsWith("Mac OS X")) { 55 toolsJar = new File ("/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar"); 56 } else { 57 System.out.println("Java SDK not found: " + toolsJar); 58 System.out.println("Please set JAVA_HOME to the SDK home directory."); 59 System.out.println("SnipSnap will run, but you cannot use source JSP files."); 60 } 61 } 62 try { 63 System.setProperty(Launcher.CLASSPATH, toolsJar.getCanonicalPath()); 64 } catch (IOException e) { 65 System.out.println("SnipSnapLauncher: unable to add java compiler library: " + e.getMessage()); 66 } 67 68 try { 69 File errorLog = null; 70 if (System.getProperty("launcher.errlog") != null) { 71 errorLog = new File (System.getProperty("launcher.errlog")); 72 } else { 73 errorLog = File.createTempFile("snipsnap_", ".log"); 74 } 75 System.err.println("Launcher: System.err redirected to " + errorLog.getPath()); 76 System.setErr(new PrintStream (new FileOutputStream (errorLog))); 77 } catch (IOException e) { 78 System.err.println("Launcher: unable to redirect error log: " + e.getMessage()); 79 } 80 81 try { 82 invokeMain("org.snipsnap.server.AppServer", args); 83 } catch (Exception e) { 84 System.out.println("SnipSnapLauncher: unable to start server: " + e.getMessage()); 85 e.printStackTrace(); 86 } 87 } 88 } | Popular Tags |