Example usage for java.lang System setProperty

List of usage examples for java.lang System setProperty

Introduction

In this page you can find the example usage for java.lang System setProperty.

Prototype

public static String setProperty(String key, String value) 

Source Link

Document

Sets the system property indicated by the specified key.

Usage

From source file:net.doubledoordev.backend.Main.java

public static void main(String[] args) throws Exception {
    System.setProperty("file.encoding", "UTF-8");
    Field charset = Charset.class.getDeclaredField("defaultCharset");
    charset.setAccessible(true);/* w w  w . jav a 2s . c o m*/
    charset.set(null, null);

    for (String arg : args) {
        if (arg.equalsIgnoreCase("debug"))
            debug = true;
    }

    LOGGER.info("\n\n    D3Backend  Copyright (C) 2015  Dries007 & Double Door Development\n"
            + "    This program comes with ABSOLUTELY NO WARRANTY;\n"
            + "    This is free software, and you are welcome to redistribute it under certain conditions;\n"
            + "    Type `license' for details.\n\n");

    LOGGER.info("Making necessary folders...");
    mkdirs();
    LOGGER.info("Starting webserver...");

    final HttpServer webserver = new HttpServer();
    final ServerConfiguration config = webserver.getServerConfiguration();

    // Html stuff
    freemarkerHandler = new FreemarkerHandler(Main.class, TEMPLATES_PATH);
    config.addHttpHandler(freemarkerHandler);
    config.setDefaultErrorPageGenerator(freemarkerHandler);
    config.addHttpHandler(new CLStaticHttpHandler(Main.class.getClassLoader(), STATIC_PATH), STATIC_PATH);
    config.addHttpHandler(new ServerFileHandler(P2S_PATH), P2S_PATH);
    config.addHttpHandler(new ServerFileHandler(), RAW_PATH);

    // Socket stuff
    ServerMonitorSocketApplication.register();
    ServerControlSocketApplication.register();
    ServerPropertiesSocketApplication.register();
    FileManagerSocketApplication.register();
    ServerconsoleSocketApplication.register();
    ConsoleSocketApplication.register();
    AdvancedSettingsSocketApplication.register();
    UsersSocketApplication.register();

    final NetworkListener networkListener = new NetworkListener("listener",
            Strings.isBlank(SETTINGS.hostname) ? NetworkListener.DEFAULT_NETWORK_HOST : SETTINGS.hostname,
            Strings.isNotBlank(SETTINGS.certificatePath) ? SETTINGS.portHTTPS : SETTINGS.portHTTP);
    if (Strings.isNotBlank(SETTINGS.certificatePath)) {
        networkListener.setSecure(true);
        networkListener.setSSLEngineConfig(createSslConfiguration());
        webserver.addListener(new NetworkListener("redirect-listener",
                Strings.isBlank(SETTINGS.hostname) ? NetworkListener.DEFAULT_NETWORK_HOST : SETTINGS.hostname,
                SETTINGS.portHTTP));
    }
    webserver.addListener(networkListener);
    networkListener.registerAddOn(new WebSocketAddOn());
    webserver.start();

    LOGGER.info("Setting up caching...");
    Cache.init();

    if (SETTINGS.users.isEmpty()) {
        adminKey = UUID.randomUUID().toString();
        LOGGER.warn("Your userlist is empty.");
        LOGGER.warn("Make a new account and use the special admin token in the '2 + 2 = ?' field.");
        LOGGER.warn(
                "You can only use this key once. It will be regenerated if the userlist is empty when the backend starts.");
        LOGGER.warn("Admin token: " + adminKey);
    }

    LOGGER.info("Use the help command for help.");

    CommandHandler.init();
    for (Server server : SETTINGS.servers.values()) {
        server.init();
        if (server.getRestartingInfo().autoStart) {
            try {
                server.startServer();
            } catch (Exception ignored) {
                ignored.printStackTrace();
            }
        }
    }
}

From source file:org.wso2.carbon.appmgt.sampledeployer.main.ApplicationPublisher.java

public static void main(String[] args) {
    tomcatPort = args[0];/*  ww w  .j ava 2s.c  om*/
    appmPath = args[1];
    username = args[2];
    password = args[3];
    tomcatPath = args[4];
    lampPath = args[5];
    ipAddress = args[6];
    hitCount = Integer.parseInt(args[7]);
    System.setProperty("javax.net.ssl.trustStore", appmPath + "/repository/resources/security/wso2carbon.jks");
    System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
    System.setProperty("javax.net.ssl.trustStoreType", "JKS");
    log.info("initialising properties");
    log.info("Tomcat port : " + tomcatPort);
    log.info("APPM path : " + appmPath);
    log.info("Username : " + username);
    log.info("Password : " + password);
    log.info("Tomcat path : " + tomcatPath);
    log.info("LAMP path : " + lampPath);
    log.info("IP Address : " + ipAddress);
    log.info("Hit count : " + hitCount);
    trackingCodes = new ConcurrentHashMap<String, String>();
    configure();
    //startServers();
    try {
        log.info("Starting Servers.....");
        Thread.sleep(5000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    /*trackingCodes.put("/notifi","AM_995364166653157224");
    trackingCodes.put("/travelBooking","AM_14359451055881852910");
    trackingCodes.put("/travel","AM_10574531036724348945");*/
    for (String key : trackingCodes.keySet()) {
        accsesWebPages(key, trackingCodes.get(key), hitCount);
    }
}

From source file:com.hs.mail.container.simple.SimpleSpringContainer.java

/**
* @param args/*from w w w  .  j a  va2  s. c  o  m*/
*/
public static void main(String[] args) {
    CommandLine cli = null;
    try {
        cli = new PosixParser().parse(OPTS, args);
    } catch (ParseException e) {
        usage();
        System.exit(0);
    }

    try {
        String configLocation = cli.getOptionValue("c", DEFAULT_CONFIG_LOCATION);
        System.setProperty("app.home", new File(configLocation).getParentFile().getParent());
        SimpleSpringContainer container = new SimpleSpringContainer(new String[] { configLocation });
        container.start();

        if (cli.hasOption("dm")) {
            startPerformanceMonitor(cli.getOptionValue("dm", "5"));
        }
    } catch (Exception e) {
        String errMsg = (e.getMessage() != null) ? e.getMessage() : e.getCause().getMessage();
        System.err.println(errMsg);
        logger.fatal(errMsg, e);
    }
}

From source file:com.ebay.jetstream.application.JetstreamApplication.java

/**
 * Every Jetstream application shares a common main(). It creates the instance of the application, configures command
 * line options, parses the command line based on the options, starts the application based on the resulting
 * configuration, and then runs the application.
 * //from ww w . j av a  2 s.  c  o  m
 * @param args
 *          command line arguments
 */
public static void main(String[] args) throws Exception {
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");
    JetstreamApplication ta = null;
    try {
        ta = getInstance();
        // Allow JetstreamApplication option handling methods to be protected
        final JetstreamApplication optionHandler = ta;
        new CliOptions(new CliOptionHandler() {
            public Options addOptions(Options options) {
                return optionHandler.addOptions(options);
            }

            public void parseOptions(CommandLine line) {
                optionHandler.parseOptions(line);
            }
        }, args);

        if (System.getenv("COS") == null)
            System.setProperty("COS", "Dev");

        ta.init();
    } catch (Exception e) {
        LOGGER.error("Failed to start Application" + e.getLocalizedMessage());
        System.err.println("Failed to start application: " + e);
        e.printStackTrace(System.err);
        System.exit(1);
    }
    ta.run(); // this is the container's event loop
}

From source file:com.netflix.iep.eureka.EurekaModule.java

public static void main(String[] args) {
    System.setProperty("netflix.iep.archaius.use-dynamic", "false");
    Injector injector = Guice.createInjector(new EurekaModule());
    AdminServer server = injector.getInstance(AdminServer.class);
    server.start();/*from  w  w  w.java2 s  .c om*/
}

From source file:avantssar.aslanpp.testing.Tester.java

public static void main(String[] args) {

    Debug.initLog(LogLevel.INFO);/*from   w w  w.j  a va 2 s.  c  o m*/

    TesterCommandLineOptions options = new TesterCommandLineOptions();
    try {
        options.getParser().parseArgument(args);
        options.ckeckAtEnd();
    } catch (CmdLineException ex) {
        reportException("Inconsistent options.", ex, System.err);
        options.showShortHelp(System.err);
        return;
    }

    if (options.isShowHelp()) {
        options.showLongHelp(System.out);
        return;
    }

    ASLanPPConnectorImpl translator = new ASLanPPConnectorImpl();

    if (options.isShowVersion()) {
        System.out.println(translator.getFullTitleLine());
        return;
    }

    ISpecificationBundleProvider sbp;
    File realInDir;
    if (options.isLibrary()) {
        if (options.getHornClausesLevel() != HornClausesLevel.ALL) {
            System.out.println("When checking the internal library we output all Horn clauses.");
            options.setHornClausesLevel(HornClausesLevel.ALL);
        }
        if (!options.isStripOutput()) {
            System.out.println(
                    "When checking the internal library, the ouput is stripped of comments and line information.");
            options.setStripOutput(true);
        }
        File modelsDir = new File(FilenameUtils.concat(options.getOut().getAbsolutePath(), "_models"));
        try {
            FileUtils.forceMkdir(modelsDir);
        } catch (IOException e1) {
            System.out.println("Failed to create models folder: " + e1.getMessage());
            Debug.logger.error("Failed to create models folder.", e1);
        }
        realInDir = modelsDir;
        sbp = new LibrarySpecificationsProvider(modelsDir.getAbsolutePath());
    } else {
        realInDir = options.getIn();
        sbp = new DiskSpecificationsProvider(options.getIn().getAbsolutePath());
    }

    System.setProperty(EntityManager.ASLAN_ENVVAR, sbp.getASLanPath());
    // try {
    // EntityManager.loadASLanPath();
    // }
    // catch (IOException e) {
    // System.out.println("Exception while reloading ASLANPATH: " +
    // e.getMessage());
    // Debug.logger.error("Exception while loading ASLANPATH.", e);
    // }

    try {
        bm = BackendsManager.instance();
        if (bm != null) {
            for (IBackendRunner br : bm.getBackendRunners()) {
                System.out.println(br.getFullDescription());
                if (br.getTimeout() > finalTimeout) {
                    finalTimeout = br.getTimeout();
                }
            }
        }
    } catch (IOException e) {
        System.out.println("Failed to load backends: " + e);
    }

    int threadsCount = 50;
    if (options.getThreads() > 0) {
        threadsCount = options.getThreads();
    }
    System.out.println("Will launch " + threadsCount
            + " threads in parallel (+ will show that a thread starts, - that a thread ends).");
    TranslationReport rep = new TranslationReport(
            bm != null ? bm.getBackendRunners() : new ArrayList<IBackendRunner>(), options.getOut());
    long startTime = System.currentTimeMillis();
    int specsCount = 0;
    pool = Executors.newFixedThreadPool(threadsCount);
    for (ITestTask task : sbp) {
        doTest(rep, task, realInDir, options.getOut(), translator, options, System.err);
        specsCount++;
    }
    pool.shutdown();
    String reportFile = FilenameUtils.concat(options.getOut().getAbsolutePath(), "index.html");
    try {
        while (!pool.awaitTermination(finalTimeout, TimeUnit.SECONDS)) {
        }
    } catch (InterruptedException e) {
        Debug.logger.error("Interrupted while waiting for pool termination.", e);
        System.out.println("Interrupted while waiting for pool termination: " + e.getMessage());
        System.out.println("The report may be incomplete.");
    }
    long endTime = System.currentTimeMillis();
    long duration = (endTime - startTime) / 1000;
    System.out.println();
    System.out.println(specsCount + " specifications checked in " + duration + " seconds.");
    rep.report(reportFile);
    System.out.println("You can find an overview report at '" + reportFile + "'.");
}

From source file:org.kurento.room.demo.KurentoRoomDemoApp.java

public static void main(String[] args) throws Exception {
    log.info("Using /dev/urandom for secure random generation");
    System.setProperty("java.security.egd", "file:/dev/./urandom");
    SpringApplication.run(KurentoRoomDemoApp.class, args);
}

From source file:com.hortonworks.atlas.trash.MySqlIngester.java

public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub

    if (args.length < 1) {
        throw new Exception("Please provide the DGI host url");
    }/*from w ww .  ja  v  a2s.  co m*/

    System.setProperty("atlas.conf", "/Users/sdutta/Applications/conf");

    String baseUrl = getServerUrl(args);

    MySqlIngester sqlIngester = new MySqlIngester(baseUrl);

    sqlIngester.createTypes();
    System.out.println("Creating Entitites");
    sqlIngester.createEntities("testers", "this is data being laoded", "TestDB");

}

From source file:com.moss.appsnap.server.AppSnapServer.java

public static void main(String[] args) throws Exception {
    System.setProperty("org.mortbay.log.class", Slf4jLog.class.getName());

    File log4jConfigFile = new File("log4j.xml");

    if (log4jConfigFile.exists()) {
        DOMConfigurator.configureAndWatch(log4jConfigFile.getAbsolutePath(), 1000);
    } else {//  www .jav  a 2  s  . co m
        BasicConfigurator.configure();
        Logger.getRootLogger().setLevel(Level.INFO);
    }

    ServerConfiguration config;

    JAXBContext context = JAXBContext.newInstance(ServerConfiguration.class, VeracityId.class);
    JAXBHelper helper = new JAXBHelper(context);

    Logger log = Logger.getLogger(AppSnapServer.class);

    File[] configPaths = new File[] { new File("settings.xml"),
            new File(new File(System.getProperty("user.home")), ".appsnap-server.xml"),
            new File("/etc/appsnap-server.xml") };

    File configFile = null;

    for (File next : configPaths) {
        if (next.exists()) {
            configFile = next;
        }
    }

    if (configFile == null) {

        log.warn("No config file found.");

        for (int x = configPaths.length - 1; x >= 0; x--) {
            File next = configPaths[x];
            log.warn("Attempting to create default config file at " + next.getAbsolutePath());
            ServerConfiguration defaults = new ServerConfiguration();
            defaults.idProofRecipie(
                    new PasswordProofRecipie(new SimpleId("mr-admin-dude"), "my-super-secret-password"));
            try {
                helper.writeToFile(helper.writeToXmlString(defaults), next);
                log.warn("done");
                break;
            } catch (Exception e) {
                log.warn("Error writing file: " + e.getMessage(), e);
            }
        }
        System.exit(1);
        return;
    } else {
        log.info("Reading configuration from " + configFile.getAbsolutePath());
        config = helper.readFromFile(configFile);
    }

    ProxyFactory proxyFactory = new ProxyFactory(new HessianProxyProvider());
    try {
        new AppSnapServer(config, proxyFactory);
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Unexpected Error.  Shutting Down.");
        System.exit(1);
    }
}

From source file:scalespace.filter.Gaussian_Derivative_.java

public static void main(String[] args) {

    try {//w w w. j ava  2 s . c  om

        File f = new File(args[0]);

        if (f.exists() && f.isDirectory()) {
            System.setProperty("plugins.dir", args[0]);
            new ImageJ();
        } else {
            throw new IllegalArgumentException();
        }
    } catch (Exception ex) {
        IJ.log("plugins.dir misspecified\n");
        ex.printStackTrace();
    }

}