List of usage examples for java.lang System getProperty
public static String getProperty(String key)
From source file:com.ibm.replication.iidr.utils.Settings.java
public static void main(String[] args) throws ConfigurationException, IllegalArgumentException, IllegalAccessException, FileNotFoundException, IOException { System.setProperty("log4j.configurationFile", System.getProperty("user.dir") + File.separatorChar + "conf" + File.separatorChar + "log4j2.xml"); LoggerContext ctx = (LoggerContext) LogManager.getContext(false); Configuration config = ctx.getConfiguration(); LoggerConfig loggerConfig = config.getLoggerConfig("com.ibm.replication.iidr.utils.Settings"); loggerConfig.setLevel(Level.DEBUG); ctx.updateLoggers();//from w w w. jav a2s . c o m new Settings("CollectCDCStats.properties"); }
From source file:OS.java
/** * @param args the command line arguments *//*from w ww . j ava2 s . c o m*/ public static void main(String args[]) { System.out.println("os.version = " + System.getProperty("os.version")); System.out.println("os.name = " + System.getProperty("os.name")); System.out.println("os.arch = " + System.getProperty("os.arch")); System.out.println("isUNIX() returned: " + isUNIX()); System.out.println("isWindows() returned: " + isWindows()); System.out.println("isWindowsForSure() returned: " + isWindowsForSure()); System.out.println("isSun() returned: " + isSun()); System.out.println("isLinux() returned: " + isLinux()); System.out.println("isDebianLinux() returned: " + isDebianLinux()); System.out.println("isFedoraLinux() returned: " + isFedoraLinux()); System.out.println("isGentooLinux() returned: " + isGentooLinux()); System.out.println("isKnoppixLinux() returned: " + isKnoppixLinux()); System.out.println("isMandrakeLinux() returned: " + isMandrakeLinux()); System.out.println("isMandrivaLinux() returned: " + isMandrivaLinux()); System.out.println("isRedHatLinux() returned: " + isRedHatLinux()); System.out.println("isSlackwareLinux() returned: " + isSlackwareLinux()); System.out.println("isSuSELinux() returned: " + isSuSELinux()); System.out.println("isUbuntuLinux() returned: " + isUbuntuLinux()); System.out.println("isSunX86() returned: " + isSunX86()); System.out.println("isSunSparc() returned: " + isSunSparc()); System.out.println("isDarwin() returned: " + isDarwin()); System.out.println("isSolaris10() returned: " + isSolaris10()); }
From source file:de.uni_koblenz.jgralab.utilities.tgraphbrowser.TGraphBrowserServer.java
/** * Runs the server. Needed args: -w --workspace the workspace * //from ww w . j a v a 2s . co m * @param args */ public static void main(String[] args) { CommandLine comLine = processCommandLineOptions(args); assert comLine != null; try { starttime = System.currentTimeMillis(); String portnumber = comLine.getOptionValue("p"); String workspacePath; if (comLine.hasOption("r")) { TwoDVisualizer.PRINT_ROLE_NAMES = true; } if (comLine.hasOption("w")) { workspacePath = comLine.getOptionValue("w"); } else { File workspace = new File(System.getProperty("java.io.tmpdir") + File.separator + "tgraphbrowser"); if (!workspace.exists()) { if (!workspace.mkdir()) { logger.info("The temp folder " + workspace.getAbsolutePath() + " could not be created."); } } workspace = new File(workspace.getAbsoluteFile() + File.separator + "workspace"); if (!workspace.exists()) { if (!workspace.mkdir()) { logger.info( "The default workspace " + workspace.getAbsolutePath() + " could not be created."); } } workspacePath = workspace.getAbsolutePath(); } new TGraphBrowserServer(portnumber == null ? DEFAULT_PORT : Integer.parseInt(portnumber), workspacePath, comLine.getOptionValue("m"), comLine.getOptionValue("s")).start(); if (comLine.getOptionValue("ic") != null) { TabularVisualizer.NUMBER_OF_INCIDENCES_PER_PAGE = Math .max(Integer.parseInt(comLine.getOptionValue("ic")), 1); } if (comLine.hasOption("d")) { StateRepository.dot = comLine.getOptionValue("d"); } else { System.out.println("The 2D-Visualization is disabled because parameter -d is not set."); } String timeout = comLine.getOptionValue("t"); String checkIntervall = comLine.getOptionValue("i"); new DeleteUnusedStates(timeout == null ? 600 : Integer.parseInt(timeout), checkIntervall == null ? 60 : Integer.parseInt(checkIntervall)).start(); if (comLine.hasOption("td")) { TwoDVisualizer.SECONDS_TO_WAIT_FOR_DOT = Integer.parseInt(comLine.getOptionValue("td")); } } catch (IOException e) { System.out.println(e); } }
From source file:com.ericsson.eiffel.remrem.semantics.clone.PrepareLocalEiffelSchemas.java
public static void main(String[] args) throws IOException { final PrepareLocalEiffelSchemas prepareLocalSchema = new PrepareLocalEiffelSchemas(); final Proxy proxy = prepareLocalSchema.getProxy(httpProxyUrl, httpProxyPort, httpProxyUsername, httpProxyPassword);/*from w w w. j av a 2s .c o m*/ if (proxy != null) { prepareLocalSchema.setProxy(proxy); } final String eiffelRepoUrl = args[0]; final String eiffelRepoBranch = args[1]; final String operationRepoUrl = args[2]; final String operationRepoBranch = args[3]; final File localEiffelRepoPath = new File( System.getProperty(EiffelConstants.USER_HOME) + File.separator + EiffelConstants.EIFFEL); final File localOperationsRepoPath = new File(System.getProperty(EiffelConstants.USER_HOME) + File.separator + EiffelConstants.OPERATIONS_REPO_NAME); // Clone Eiffel Repo from GitHub prepareLocalSchema.cloneEiffelRepo(eiffelRepoUrl, eiffelRepoBranch, localEiffelRepoPath); //Clone Eiffel operations Repo from GitHub prepareLocalSchema.cloneEiffelRepo(operationRepoUrl, operationRepoBranch, localOperationsRepoPath); //Copy operations repo Schemas to location where Eiffel repo schemas available prepareLocalSchema.copyOperationSchemas(localOperationsRepoPath.getAbsolutePath(), localEiffelRepoPath.getAbsolutePath()); // Read and Load JsonSchemas from Cloned Directory final LocalRepo localRepo = new LocalRepo(localEiffelRepoPath); localRepo.readSchemas(); final ArrayList<String> jsonEventNames = localRepo.getJsonEventNames(); final ArrayList<File> jsonEventSchemas = localRepo.getJsonEventSchemas(); // Schema changes final SchemaFile schemaFile = new SchemaFile(); // Iterate the Each jsonSchema file to Add and Modify the necessary properties if (jsonEventNames != null && jsonEventSchemas != null) { for (int i = 0; i < jsonEventNames.size(); i++) { schemaFile.modify(jsonEventSchemas.get(i), jsonEventNames.get(i)); } } }
From source file:com.cazcade.billabong.store.impl.CloudFilesBasedBinaryStore.java
public static void main(String[] args) throws Exception { FilesClient client = new FilesClient(System.getProperty("cloudfiles.username"), System.getProperty("cloudfiles.apikey")); boolean loggedin = client.login(); if (loggedin) { System.out.println("Logged in."); List<FilesContainer> containers = client.listContainers(); System.out.println("Container count: " + containers.size()); for (FilesContainer container : containers) { System.out.println("\tContainer: " + container.getName()); }// w w w.j a v a 2 s .c o m byte[] file = "<html><body>Hello World</body></html>".getBytes("UTF-8"); client.storeObject("public", file, "text/html", "test.html", new HashMap<String, String>()); List<FilesCDNContainer> cdnContainers = client.listCdnContainerInfo(); System.out.println("CDN Container count: " + cdnContainers.size()); for (FilesCDNContainer container : cdnContainers) { System.out.println("\tContainer: " + container.getName()); System.out.println("\tContainer URL: " + container.getCdnURL()); List<FilesObject> contents = client.listObjects(container.getName()); System.out.println("\tFile Count: " + contents.size()); // for (FilesObject fileObject : contents) { // System.out.println("\t\tFile: " + fileObject.getName()); // System.out.println("\t\tContent Type: " + fileObject.getMimeType()); // System.out.println("\t\tModified:" + fileObject.getLastModified()); // } } } }
From source file:de.prozesskraft.ptest.Launch.java
public static void main(String[] args) throws org.apache.commons.cli.ParseException, IOException { // try//from w w w . j a va2 s.c o m // { // if (args.length != 3) // { // System.out.println("Please specify processdefinition file (xml) and an outputfilename"); // } // // } // catch (ArrayIndexOutOfBoundsException e) // { // System.out.println("***ArrayIndexOutOfBoundsException: Please specify processdefinition.xml, openoffice_template.od*, newfile_for_processdefinitions.odt\n" + e.toString()); // } /*---------------------------- get options from ini-file ----------------------------*/ File inifile = new java.io.File( WhereAmI.getInstallDirectoryAbsolutePath(Launch.class) + "/" + "../etc/ptest-launch.ini"); if (inifile.exists()) { try { ini = new Ini(inifile); } catch (InvalidFileFormatException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else { System.err.println("ini file does not exist: " + inifile.getAbsolutePath()); System.exit(1); } /*---------------------------- create boolean options ----------------------------*/ Option ohelp = new Option("help", "print this message"); Option ov = new Option("v", "prints version and build-date"); /*---------------------------- create argument options ----------------------------*/ Option ospl = OptionBuilder.withArgName("DIR").hasArg() .withDescription("[mandatory] directory with sample input data") // .isRequired() .create("spl"); Option oinstancedir = OptionBuilder.withArgName("DIR").hasArg() .withDescription("[mandatory, default: .] directory where the test will be performed") // .isRequired() .create("instancedir"); Option ocall = OptionBuilder.withArgName("FILE").hasArg() .withDescription("[mandatory, default: random call in spl-directory] file with call-string") // .isRequired() .create("call"); Option oaltapp = OptionBuilder.withArgName("STRING").hasArg() .withDescription( "[optional] alternative app. this String replaces the first line of the .call-file.") // .isRequired() .create("altapp"); Option oaddopt = OptionBuilder.withArgName("STRING").hasArg() .withDescription("[optional] add an option to the call.") // .isRequired() .create("addopt"); Option onolaunch = new Option("nolaunch", "only create instance directory, copy all spl files, but do NOT launch the process"); /*---------------------------- create options object ----------------------------*/ Options options = new Options(); options.addOption(ohelp); options.addOption(ov); options.addOption(ospl); options.addOption(oinstancedir); options.addOption(ocall); options.addOption(oaltapp); options.addOption(oaddopt); options.addOption(onolaunch); /*---------------------------- create the parser ----------------------------*/ CommandLineParser parser = new GnuParser(); try { // parse the command line arguments commandline = parser.parse(options, args); } catch (Exception exp) { // oops, something went wrong System.err.println("Parsing failed. Reason: " + exp.getMessage()); exiter(); } /*---------------------------- usage/help ----------------------------*/ if (commandline.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("launch", options); System.exit(0); } else if (commandline.hasOption("v")) { System.out.println("web: " + web); System.out.println("author: " + author); System.out.println("version:" + version); System.out.println("date: " + date); System.exit(0); } /*---------------------------- ueberpruefen ob eine schlechte kombination von parametern angegeben wurde ----------------------------*/ boolean error = false; String spl = null; String instancedir = null; String call = null; String altapp = null; ArrayList<String> addopt = new ArrayList<String>(); // spl initialisieren if (commandline.hasOption("spl")) { spl = commandline.getOptionValue("spl"); } else { System.err.println("option -spl is mandatory"); error = true; } // instancedir initialisieren if (commandline.hasOption("instancedir")) { instancedir = commandline.getOptionValue("instancedir"); } else { instancedir = System.getProperty("user.dir"); } // call initialisieren if (commandline.hasOption("call")) { call = commandline.getOptionValue("call"); } // altapp initialisieren if (commandline.hasOption("altapp")) { altapp = commandline.getOptionValue("altapp"); } // addopt initialisieren if (commandline.hasOption("addopt")) { for (String actString : commandline.getOptionValues("addopt")) { addopt.add(actString); } } // wenn fehler, dann exit if (error) { exiter(); } /*---------------------------- die lizenz ueberpruefen und ggf abbrechen ----------------------------*/ // check for valid license ArrayList<String> allPortAtHost = new ArrayList<String>(); allPortAtHost.add(ini.get("license-server", "license-server-1")); allPortAtHost.add(ini.get("license-server", "license-server-2")); allPortAtHost.add(ini.get("license-server", "license-server-3")); MyLicense lic = new MyLicense(allPortAtHost, "1", "user-edition", "0.1"); // lizenz-logging ausgeben for (String actLine : (ArrayList<String>) lic.getLog()) { System.err.println(actLine); } // abbruch, wenn lizenz nicht valide if (!lic.isValid()) { System.exit(1); } /*---------------------------- die eigentliche business logic ----------------------------*/ // das erste spl-objekt geben lassen Spl actSpl = new Splset(spl).getSpl().get(0); // den call, result und altapp ueberschreiben actSpl.setName("default"); if (call != null) { actSpl.setCall(new java.io.File(call)); } if (actSpl.getCall() == null) { System.err.println("error: no call information found"); System.exit(1); } if (altapp != null) { actSpl.setAltapp(altapp); } if (addopt.size() > 0) { actSpl.setAddopt(addopt); } actSpl.setResult(null); // das instancedir erstellen java.io.File actSplInstanceDir = new java.io.File(instancedir); System.err.println("info: creating directory " + actSplInstanceDir.getCanonicalPath()); actSplInstanceDir.mkdirs(); // Inputdaten in das InstanceDir exportieren actSpl.exportInput(actSplInstanceDir); // exit, wenn --nolaunch if (commandline.hasOption("nolaunch")) { System.err.println("info: exiting, because of -nolaunch"); System.exit(0); } // das logfile des Syscalls (zum debuggen des programms "process syscall" gedacht) String AbsLogSyscallWrapper = actSplInstanceDir.getCanonicalPath() + "/.log"; String AbsStdout = actSplInstanceDir.getCanonicalPath() + "/.stdout.txt"; String AbsStderr = actSplInstanceDir.getCanonicalPath() + "/.stderr.txt"; String AbsPid = actSplInstanceDir.getCanonicalPath() + "/.pid"; // beim starten von syscall werden parameter mit whitespaces an diesen auseinandergeschnitten und der nachfolgende aufruf schlaeft fehl // deshalb sollen whitespaces durch eine 'zeichensequenz' ersetzt werden // syscall ersetzt die zeichensequenz wieder zurueck in ein " " ArrayList<String> callFuerSyscall = actSpl.getCallAsArrayList(); ArrayList<String> callFuerSyscallMitTrennzeichen = new ArrayList<String>(); for (String actString : callFuerSyscall) { callFuerSyscallMitTrennzeichen.add(actString.replaceAll("\\s+", "%WHITESPACE%")); } try { // den Aufrufstring fuer die externe App (process syscall --version 0.6.0)) splitten // beim aufruf muss das erste argument im path zu finden sein, sonst gibt die fehlermeldung 'no such file or directory' ArrayList<String> processSyscallWithArgs = new ArrayList<String>( Arrays.asList(ini.get("apps", "pkraft-syscall").split(" "))); // die sonstigen argumente hinzufuegen processSyscallWithArgs.add("-call"); processSyscallWithArgs.add(String.join(" ", callFuerSyscallMitTrennzeichen)); // processSyscallWithArgs.add("\""+call+"\""); processSyscallWithArgs.add("-stdout"); processSyscallWithArgs.add(AbsStdout); processSyscallWithArgs.add("-stderr"); processSyscallWithArgs.add(AbsStderr); processSyscallWithArgs.add("-pid"); processSyscallWithArgs.add(AbsPid); processSyscallWithArgs.add("-mylog"); processSyscallWithArgs.add(AbsLogSyscallWrapper); processSyscallWithArgs.add("-maxrun"); processSyscallWithArgs.add("" + 3000); // erstellen prozessbuilder ProcessBuilder pb = new ProcessBuilder(processSyscallWithArgs); // erweitern des PATHs um den prozesseigenen path // Map<String,String> env = pb.environment(); // String path = env.get("PATH"); // log("debug", "$PATH="+path); // path = this.parent.getAbsPath()+":"+path; // env.put("PATH", path); // log("info", "path: "+path); // setzen der aktuellen directory (in der syscall ausgefuehrt werden soll) java.io.File directory = new java.io.File(instancedir); System.err.println("info: setting execution directory to: " + directory.getCanonicalPath()); pb.directory(directory); // zum debuggen ein paar ausgaben // java.lang.Process p1 = Runtime.getRuntime().exec("date >> ~/tmp.debug.work.txt"); // p1.waitFor(); // java.lang.Process p2 = Runtime.getRuntime().exec("ls -la "+this.getParent().getAbsdir()+" >> ~/tmp.debug.work.txt"); // p2.waitFor(); // java.lang.Process pro = Runtime.getRuntime().exec("nautilus"); // java.lang.Process superpro = Runtime.getRuntime().exec(processSyscallWithArgs.toArray(new String[processSyscallWithArgs.size()])); // p3.waitFor(); System.err.println("info: calling: " + pb.command()); // starten des prozesses java.lang.Process sysproc = pb.start(); // einfangen der stdout- und stderr des subprozesses InputStream is_stdout = sysproc.getInputStream(); InputStream is_stderr = sysproc.getErrorStream(); // Send your InputStream to an InputStreamReader: InputStreamReader isr_stdout = new InputStreamReader(is_stdout); InputStreamReader isr_stderr = new InputStreamReader(is_stderr); // That needs to go to a BufferedReader: BufferedReader br_stdout = new BufferedReader(isr_stdout); BufferedReader br_stderr = new BufferedReader(isr_stderr); // // oeffnen der OutputStreams zu den Ausgabedateien // FileWriter fw_stdout = new FileWriter(sStdout); // FileWriter fw_stderr = new FileWriter(sStderr); // zeilenweise in die files schreiben String line_out = new String(); String line_err = new String(); while (br_stdout.readLine() != null) { } // while (((line_out = br_stdout.readLine()) != null) || ((line_err = br_stderr.readLine()) != null)) // { // if (!(line_out == null)) // { // System.out.println(line_out); // System.out.flush(); // } // if (!(line_err == null)) // { // System.err.println(line_err); // System.err.flush(); // } // } int exitValue = sysproc.waitFor(); // fw_stdout.close(); // fw_stderr.close(); System.err.println("exitvalue: " + exitValue); sysproc.destroy(); System.exit(exitValue); // alternativer aufruf // java.lang.Process sysproc = Runtime.getRuntime().exec(StringUtils.join(args_for_syscall, " ")); // log("info", "call executed. pid="+sysproc.hashCode()); // wait 2 seconds for becoming the pid-file visible // Thread.sleep(2000); // int exitValue = sysproc.waitFor(); // // der prozess soll bis laengstens // if(exitValue != 0) // { // System.err.println("error: call returned a value indicating an error: "+exitValue); // } // else // { // System.err.println("info: call returned value: "+exitValue); // } // System.err.println("info: "+new Date().toString()); // System.err.println("info: bye"); // // sysproc.destroy(); // // System.exit(sysproc.exitValue()); } catch (Exception e2) { System.err.println("error: " + e2.getMessage()); System.exit(1); } }
From source file:CSVWriter.java
/** * Test driver/* ww w .j a va 2 s . c om*/ * * @param args [0]: The name of the file. */ static public void main(String[] args) { try { // write out a test file PrintWriter pw = new PrintWriter(new FileWriter(args[0])); CSVWriter csv = new CSVWriter(pw, false, ',', System.getProperty("line.separator")); csv.writeCommentln("This is a test csv-file: '" + args[0] + "'"); csv.write("abc"); csv.write("def"); csv.write("g h i"); csv.write("jk,l"); csv.write("m\"n\'o "); csv.writeln(); csv.write("m\"n\'o "); csv.write(" "); csv.write("a"); csv.write("x,y,z"); csv.write("x;y;z"); csv.writeln(); csv.writeln(new String[] { "This", "is", "an", "array." }); csv.close(); } catch (IOException e) { e.printStackTrace(); System.out.println(e.getMessage()); } }
From source file:com.clearspring.metriccatcher.Loader.java
/** * Create a loader with the given properties file, if specified * on the command line.//from ww w . ja va 2 s . c o m * * @param args Optional '-c' to define a configuration file * @throws Exception */ public static void main(String[] args) throws Exception { PropertyConfigurator.configure(System.getProperty("log4j.configuration")); String propertiesFilename = defaultPropertiesFilename; // Command line arguments for (int i = 0; i < args.length; i++) { // Specify config file if ("-c".equals(args[i])) { propertiesFilename = args[++i]; } } File propertiesFile = new File(propertiesFilename); @SuppressWarnings("unused") Loader loader = new Loader(propertiesFile); }
From source file:com.justgiving.raven.kissmetrics.utils.KissmetricsLocalSchemaExtractor.java
public static void main(String[] args) throws FileNotFoundException, IOException { for (String s : args) { System.out.println(s);//from w w w . j a v a 2 s . c o m } //String inputFolder ="D:\\datasets\\kissmetrics\\input\\2250.json"; //String outputFile ="D:\\datasets\\kissmetrics\\output\\2250.json"; //String inputFolder ="D:\\datasets\\kissmetrics\\input\\"; //String inputFolder ="D:\\ouptuts\\km\\input\\"; //String inputFolder ="D:\\datasets\\kissmetrics\\input4\\revisions\\"; //String inputFolder ="D:\\datasets\\kissmetrics\\input5\\"; //String outputFile ="D:\\datasets\\kissmetrics\\output\\"; //String inputFolder ="D:\\datasets\\kinesis\\input2\\"; //String outputFile ="D:\\datasets\\kissmetrics\\output\\schema2.txt"; //String inputFolder ="D:\\datasets\\kissmetrics\\stg\\input\\"; //String outputFile ="D:\\datasets\\kissmetrics\\stg\\ouput\\schema1.txt"; String inputFolder = "D:\\datasets\\kinesis\\stg\\input2\\"; String outputFile = "D:\\datasets\\kinesis\\stg\\output2\\schema-kinesis.txt"; //String inputFolder ="D:\\datasets\\kissmetrics\\prd\\input1\\"; //String outputFile ="D:\\datasets\\kissmetrics\\prd\\output1\\schema-kissmetrics.txt"; if (args.length != 2) { System.out.println("No arguments provided, using default values"); System.out.println("InputFolder/File: " + inputFolder); System.out.println("OutputFile: " + outputFile); } else { inputFolder = args[0]; outputFile = args[1]; } if ((new File(outputFile)).isDirectory()) { System.err.println("Error output file cannot be a directory"); return; } String logConfigPath = Paths.get(System.getProperty("user.dir"), "log4j.properties").toString(); System.out.println("log config file used: " + logConfigPath); PropertyConfigurator.configure(logConfigPath); logger.info("log config file used: " + logConfigPath); if (inputFolder.endsWith("\\")) { logger.info("Detected source folder"); countKeysInJsonRecordsFolder(inputFolder, outputFile); } else { logger.info("Detected source file"); countKeysInJsonRecordsFile(inputFolder); } }
From source file:com.diversityarrays.dal.server.DalServer.java
public static void main(String[] args) { String host = null;/* w ww.j a v a 2 s . c o m*/ int port = DalServerUtil.DEFAULT_DAL_SERVER_PORT; int inactiveMins = DalServerUtil.DEFAULT_MAX_INACTIVE_MINUTES; File docRoot = null; String serviceName = null; for (int i = 0; i < args.length; ++i) { String argi = args[i]; if (argi.startsWith("-")) { if ("--".equals(argi)) { break; } if ("-version".equals(argi)) { System.out.println(DAL_SERVER_VERSION); System.exit(0); } if ("-help".equals(argi)) { giveHelpThenExit(0); } if ("-docroot".equals(argi)) { if (++i >= args.length || args[i].startsWith("-")) { fatal("missing value for " + argi); } docRoot = new File(args[i]); } else if ("-sqllog".equals(argi)) { SqlUtil.logger = Logger.getLogger(SqlUtil.class.getName()); } else if ("-expire".equals(argi)) { if (++i >= args.length || args[i].startsWith("-")) { fatal("missing value for " + argi); } try { inactiveMins = Integer.parseInt(args[i], 10); if (inactiveMins <= 0) { fatal("invalid minutes: " + args[i]); } } catch (NumberFormatException e) { fatal("invalid minutes: " + args[i]); } } else if ("-localhost".equals(argi)) { host = "localhost"; } else if ("-port".equals(argi)) { if (++i >= args.length || args[i].startsWith("-")) { fatal("missing value for " + argi); } try { port = Integer.parseInt(args[i], 10); if (port < 0 || port > 65535) { fatal("invalid port number: " + args[i]); } } catch (NumberFormatException e) { fatal("invalid port number: " + args[i]); } } else { fatal("invalid option: " + argi); } } else { if (serviceName != null) { fatal("multiple serviceNames not supported: " + argi); } serviceName = argi; } } final DalServerPreferences preferences = new DalServerPreferences( Preferences.userNodeForPackage(DalServer.class)); if (docRoot == null) { docRoot = preferences.getWebRoot(new File(System.getProperty("user.dir"), "www")); } DalServer server = null; if (serviceName != null && docRoot.isDirectory()) { try { DalDatabase db = createDalDatabase(serviceName, preferences); if (db.isInitialiseRequired()) { Closure<String> progress = new Closure<String>() { @Override public void execute(String msg) { System.out.println("Database Initialisation: " + msg); } }; db.initialise(progress); } server = create(preferences, host, port, docRoot, db); } catch (NoServiceException e) { throw new RuntimeException(e); } catch (DalDbException e) { throw new RuntimeException(e); } } Image serverIconImage = null; InputStream imageIs = DalServer.class.getResourceAsStream("dalserver-24.png"); if (imageIs != null) { try { serverIconImage = ImageIO.read(imageIs); if (Util.isMacOS()) { try { MacApplication macapp = new MacApplication(null); macapp.setDockIconImage(serverIconImage); } catch (MacApplicationException e) { System.err.println(e.getMessage()); } } } catch (IOException ignore) { } } if (server != null) { server.setMaxInactiveMinutes(inactiveMins); } else { AskServerParams asker = new AskServerParams(serverIconImage, null, "DAL Server Start", docRoot, preferences); GuiUtil.centreOnScreen(asker); asker.setVisible(true); if (asker.cancelled) { System.exit(0); } host = asker.dalServerHostName; port = asker.dalServerPort; inactiveMins = asker.maxInactiveMinutes; server = create(preferences, host, port, asker.wwwRoot, asker.dalDatabase); // server.setUseSimpleDatabase(asker.useSimpleDatabase); } final DalServer f_server = server; final File f_wwwRoot = docRoot; final Image f_serverIconImage = serverIconImage; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { DalServerFactory factory = new DalServerFactory() { @Override public DalServer create(String hostName, int port, File wwwRoot, DalDatabase dalDatabase) { return DalServer.create(preferences, hostName, port, wwwRoot, dalDatabase); } }; ServerGui gui = new ServerGui(f_serverIconImage, f_server, factory, f_wwwRoot, preferences); gui.setVisible(true); } }); }