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:org.eclipse.swt.snippets.Snippet154.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("Snippet 154");
    shell.setLayout(new FillLayout());

    Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED);

    /*//from ww  w . ja  va2 s . c o m
    * Set a Windows specific AWT property that prevents heavyweight
    * components from erasing their background. Note that this
    * is a global property and cannot be scoped. It might not be
    * suitable for your application.
    */
    try {
        System.setProperty("sun.awt.noerasebackground", "true");
    } catch (NoSuchMethodError error) {
    }

    /* Create and setting up frame */
    Frame frame = SWT_AWT.new_Frame(composite);
    Panel panel = new Panel(new BorderLayout()) {
        @Override
        public void update(java.awt.Graphics g) {
            /* Do not erase the background */
            paint(g);
        }
    };
    frame.add(panel);
    JRootPane root = new JRootPane();
    panel.add(root);
    java.awt.Container contentPane = root.getContentPane();

    /* Creating components */
    int nrows = 1000, ncolumns = 10;
    Vector<Vector<String>> rows = new Vector<>();
    for (int i = 0; i < nrows; i++) {
        Vector<String> row = new Vector<>();
        for (int j = 0; j < ncolumns; j++) {
            row.addElement("Item " + i + "-" + j);
        }
        rows.addElement(row);
    }
    Vector<String> columns = new Vector<>();
    for (int i = 0; i < ncolumns; i++) {
        columns.addElement("Column " + i);
    }
    JTable table = new JTable(rows, columns);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.createDefaultColumnsFromModel();
    JScrollPane scrollPane = new JScrollPane(table);
    contentPane.setLayout(new BorderLayout());
    contentPane.add(scrollPane);

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:io.stallion.boot.MainRunner.java

/**
 * Run Stallion/*  www.ja  v a2s. c  o  m*/
 * @param args  - passed in via the command line
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    System.setProperty("java.awt.headless", "true");
    mainWithPlugins(args);
}

From source file:org.spring.data.gemfire.app.main.SpringGemFireDataClient.java

public static void main(final String[] args) {
    System.setProperty("gemfire.name", SpringGemFireDataClient.class.getSimpleName());
    SpringApplication.run(SpringGemFireDataClient.class, args);
}

From source file:io.apiman.servers.gateway_h2.Starter.java

/**
 * Main entry point for the API Gateway micro service.
 * @param args the arguments/*w  ww.  jav a  2s. com*/
 * @throws Exception when any unhandled exception occurs
 */
public static final void main(String[] args) throws Exception {
    URL resource = Starter.class.getClassLoader().getResource("users.list"); //$NON-NLS-1$
    if (resource != null) {
        System.setProperty(Users.USERS_FILE_PROP, resource.toString());
    }
    createDataSource();
    loadProperties();
    GatewayMicroService microService = new GatewayMicroService();
    microService.start();
    microService.join();
}

From source file:lince.LinceApp.java

/**
 * @param args the command line arguments
 */// ww  w . j  a  va 2 s . c  o  m
public static void main(final String[] args) {
    String vlcPath = StringUtils.EMPTY;
    try {
        if (RuntimeUtil.isWindows()) {
            vlcPath = WindowsRuntimeUtil.getVlcInstallDir();
            /*if (StringUtils.isEmpty(vlcPath)){
                vlcPath= "C:\\Program Files (x86)\\VideoLAN";
            }*/
            System.setProperty("jna.library.path", vlcPath);
            setI18n();
        }
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                LinceFrame.getInstance();
            }
        });
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error inicializando main. vlcPath@" + vlcPath, e);
    }
}

From source file:com.kotcrab.vis.editor.Main.java

public static void main(String[] args) throws Exception {
    App.init();/*from   ww w. j  a v  a2  s.c  om*/
    if (OsUtils.isMac())
        System.setProperty("java.awt.headless", "true");

    LaunchConfiguration launchConfig = new LaunchConfiguration();

    //TODO: needs some better parser
    for (int i = 0; i < args.length; i++) {
        String arg = args[i];
        if (arg.equals("--scale-ui")) {
            launchConfig.scaleUIEnabled = true;
            continue;
        }

        if (arg.equals("--project")) {
            if (i + 1 >= args.length) {
                throw new IllegalStateException("Not enough parameters for --project <project path>");
            }

            launchConfig.projectPath = args[i + 1];
            i++;
            continue;
        }

        if (arg.equals("--scene")) {
            if (i + 1 >= args.length) {
                throw new IllegalStateException("Not enough parameters for --scene <scene path>");
            }

            launchConfig.scenePath = args[i + 1];
            i++;
            continue;
        }

        Log.warn("Unrecognized command line argument: " + arg);
    }

    launchConfig.verify();

    editor = new Editor(launchConfig);

    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.setWindowedMode(1280, 720);
    config.setWindowSizeLimits(1, 1, 9999, 9999);
    config.useVsync(true);
    config.setIdleFPS(2);
    config.setWindowListener(new Lwjgl3WindowAdapter() {
        @Override
        public boolean closeRequested() {
            editor.requestExit();
            return false;
        }
    });

    try {
        new Lwjgl3Application(editor, config);
        Log.dispose();
    } catch (Exception e) {
        Log.exception(e);
        Log.fatal("Uncaught exception occurred, error report will be saved");
        Log.flush();

        if (App.eventBus != null)
            App.eventBus.post(new ExceptionEvent(e, true));

        try {
            File crashReport = new CrashReporter(Log.getLogFile().file()).processReport();
            if (new File(App.TOOL_CRASH_REPORTER_PATH).exists() == false) {
                Log.warn("Crash reporting tool not present, skipping crash report sending.");
            } else {
                CommandLine cmdLine = new CommandLine(PlatformUtils.getJavaBinPath());
                cmdLine.addArgument("-jar");
                cmdLine.addArgument(App.TOOL_CRASH_REPORTER_PATH);
                cmdLine.addArgument(ApplicationUtils.getRestartCommand().replace("\"", "%"));
                cmdLine.addArgument(crashReport.getAbsolutePath(), false);
                DefaultExecutor executor = new DefaultExecutor();
                executor.setStreamHandler(new PumpStreamHandler(null, null, null));
                executor.execute(cmdLine);
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        Log.dispose();
        System.exit(-3);
    } catch (ExceptionInInitializerError err) {
        if (OsUtils.isMac() && err.getCause() instanceof IllegalStateException) {
            if (ExceptionUtils.getStackTrace(err).contains("XstartOnFirstThread")) {
                System.out.println(
                        "Application was not launched on first thread. Restarting with -XstartOnFirstThread, add VM argument -XstartOnFirstThread to avoid this.");
                ApplicationUtils.startNewInstance();
            }
        }

        throw err;
    }
}

From source file:com.cxplonka.feature.application.Application.java

public static void main(String[] args) {
    // disable authentication in Hawtio
    System.setProperty(AuthenticationFilter.HAWTIO_AUTHENTICATION_ENABLED, "false");

    SpringApplication.run(Application.class, args);
}

From source file:com.alibaba.rocketmq.tools.command.consumer.ConsumerSubCommand.java

public static void main(String[] args) {
    System.setProperty(MixAll.NAMESRV_ADDR_PROPERTY, "127.0.0.1:9876");
    MQAdminStartup.main(new String[] { new ConsumerSubCommand().commandName(), //
            "-g", "benchmark_consumer" //
    });/* w w  w . ja  va 2  s .  c  om*/
}

From source file:com.boxupp.init.Boxupp.java

public static void main(String[] args) throws Exception {
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();/*from  w  w w .  j  ava 2s . c o  m*/

    Utilities.getInstance().createRequiredFoldersIfNotExists();
    ToolConfigurationReader toolConfig = new ToolConfigurationReader();
    Config conf = toolConfig.getConfiguration();
    AppContextBuilder appContextBuilder = new AppContextBuilder();
    DBConnectionManager connectionManager = DBConnectionManager.getInstance();
    if (connectionManager != null) {
        connectionManager.checkForProviderEntries();
    }

    String jettyPort = conf.getSetting().getPortNumber();

    final JettyServer jettyServer;
    jettyServer = (jettyPort != null) ? new JettyServer(Integer.parseInt(jettyPort)) : new JettyServer();

    HandlerCollection contexts = new HandlerCollection();

    HandlerList list = new HandlerList();
    WebSocketHandler wsHandler = new WebSocketHandler() {
        @Override
        public void configure(WebSocketServletFactory webSocketServletFactory) {
            webSocketServletFactory.register(VagrantConsole.class);
        }
    };
    ContextHandler handler = new ContextHandler();
    handler.setHandler(wsHandler);
    handler.setContextPath("/vagrantConsole/");

    list.setHandlers(new Handler[] { appContextBuilder.getStaticResourceHandler(),
            appContextBuilder.getWebAppHandler(), wsHandler });

    contexts.setHandlers(new Handler[] { list });

    jettyServer.setHandler(contexts);
    Runnable runner = new Runnable() {
        @Override
        public void run() {
            try {
                jettyServer.start();
            } catch (Exception e) {
            }
        }
    };
    EventQueue.invokeLater(runner);
    System.out.println("Boxupp Server is up at \"http://localhost:" + jettyPort);
}

From source file:eu.over9000.skadi.Main.java

public static void main(final String[] args) throws Exception {
    System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager");

    printStartupInfo(args);// w  w w .  j  av  a2s . co m

    if (!JavaVersionUtil.checkRequiredVersionIsPresent()) {
        System.err.println("Skadi requires Java " + JavaVersionUtil.REQUIRED_VERSION + ", exiting");
        return;
    }

    if (!SingleInstanceLock.startSocketLock()) {
        System.err.println("another instance is up, exiting");
        return;
    }

    Application.launch(MainWindow.class, args);

    SingleInstanceLock.stopSocketLock();

    System.exit(0);
}