Example usage for org.apache.commons.lang3 SystemUtils JAVA_VERSION

List of usage examples for org.apache.commons.lang3 SystemUtils JAVA_VERSION

Introduction

In this page you can find the example usage for org.apache.commons.lang3 SystemUtils JAVA_VERSION.

Prototype

String JAVA_VERSION

To view the source code for org.apache.commons.lang3 SystemUtils JAVA_VERSION.

Click Source Link

Document

The java.version System Property.

Usage

From source file:eu.over9000.skadi.util.JavaVersionUtil.java

public static boolean checkRequiredVersionIsPresent() {
    final JavaVersion required = new JavaVersion(REQUIRED_VERSION);
    final JavaVersion present = new JavaVersion(SystemUtils.JAVA_VERSION);

    return present.compareTo(required) >= 0;
}

From source file:net.centro.rtb.monitoringcenter.infos.JvmInfo.java

public static JvmInfo create() {
    JvmInfo jvmInfo = new JvmInfo();

    jvmInfo.specVersion = SystemUtils.JAVA_SPECIFICATION_VERSION;
    jvmInfo.classVersion = SystemUtils.JAVA_CLASS_VERSION;
    jvmInfo.jreVersion = SystemUtils.JAVA_VERSION;
    jvmInfo.jreVendor = SystemUtils.JAVA_VENDOR;
    jvmInfo.vmName = SystemUtils.JAVA_VM_NAME;
    jvmInfo.vmVendor = SystemUtils.JAVA_VM_VENDOR;
    jvmInfo.vmVersion = SystemUtils.JAVA_VM_VERSION;

    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    jvmInfo.inputArguments = new ArrayList<>(runtimeMXBean.getInputArguments());
    jvmInfo.startedTimestamp = new Date(runtimeMXBean.getStartTime());

    jvmInfo.defaultTimeZone = TimeZone.getDefault().getID();
    jvmInfo.defaultCharset = Charset.defaultCharset().displayName();

    return jvmInfo;
}

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

private static void printStartupInfo(final String[] args) {
    LOGGER.info("################################################################################");
    LOGGER.info("TIME:    " + LocalDateTime.now().toString());
    LOGGER.info("OS:      " + SystemUtils.OS_NAME + " " + SystemUtils.OS_VERSION + " " + SystemUtils.OS_ARCH);
    LOGGER.info("JAVA:    " + SystemUtils.JAVA_VERSION);
    LOGGER.info(//w w  w.j  av a2  s  . com
            "         " + SystemUtils.JAVA_RUNTIME_NAME + " <build " + SystemUtils.JAVA_RUNTIME_VERSION + ">");
    LOGGER.info("VM:      " + SystemUtils.JAVA_VM_NAME + " <build" + SystemUtils.JAVA_VM_VERSION + ", "
            + SystemUtils.JAVA_VM_INFO + ">");
    LOGGER.info("VM-ARGS: " + ManagementFactory.getRuntimeMXBean().getInputArguments());
    if (VersionRetriever.isLocalInfoAvailable()) {
        LOGGER.info("SKADI:   " + VersionRetriever.getLocalVersion() + " " + VersionRetriever.getLocalBuild()
                + " " + VersionRetriever.getLocalTimestamp());
    } else {
        LOGGER.info("SKADI:   " + "No local version info available");
    }
    LOGGER.info("ARGS:    " + Arrays.asList(args));
    LOGGER.info("################################################################################");
}

From source file:org.astrojournal.AJMain.java

/**
 * Main function. By default AstroJournal Main GUI is started. Arguments can
 * be passed. Please see AJMainConsole.printHelp() for options.
 * //ww w  .  j a  v  a2 s .  co  m
 * @param args
 */
public static void main(String[] args) {
    // Get some information for debugging
    log.debug("Application: " + AJMetaInfo.NAME.getInfo() + " " + AJMetaInfo.VERSION.getInfo());
    log.debug("Operating System: " + SystemUtils.OS_ARCH + " " + SystemUtils.OS_NAME + " "
            + SystemUtils.OS_VERSION);
    log.debug("Java: " + SystemUtils.JAVA_VENDOR + " " + SystemUtils.JAVA_VERSION);

    // Initialise dependency injection with Spring
    ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/aj_spring_default_context.xml");
    BeanFactory factory = context;
    Configuration config = (Configuration) factory.getBean("configuration");
    ConfigurationUtils configUtils = config.getConfigurationUtils();

    try {
        if (args.length == 0) {
            Generator generator = (Generator) factory.getBean("generator");
            startAJMainGUI(generator, config);
        } else if (args[0].equals("-f") || args[0].equals("--config")) {
            log.info(configUtils.printConfiguration(config));
        } else if (args[0].equals("-c") || args[0].equals("--console")) {
            AJMainConsole.main(args);
        } else if (args[0].equals("-h") || args[0].equals("--help")) {
            log.info(AJMainConsole.printHelp());
        } else if (args[0].equals("--license")) {
            log.info(AJMetaInfo.SHORT_LICENSE.getInfo());
        } else if (args[0].equals("-t") || args[0].equals("--test-latex")) {
            log.info(configUtils.printPDFLatexVersion(config));
        } else {
            log.fatal(
                    "Unrecognised option. Please, run AstroJournal with the option -h [--help] for suggestions.");
        }
    } catch (Exception ex) {
        log.error(ex, ex);
    }
}

From source file:org.lenskit.cli.Main.java

public static void main(String[] args) {
    ArgumentParser parser = ArgumentParsers.newArgumentParser("lenskit")
            .description("Work with LensKit recommenders and data.");
    Logging.addLoggingGroup(parser);/* ww w .  java 2  s . c  om*/

    Subparsers subparsers = parser.addSubparsers().metavar("COMMAND").title("commands");
    ServiceLoader<Command> loader = ServiceLoader.load(Command.class);
    for (Command cmd : loader) {
        Subparser cp = subparsers.addParser(cmd.getName()).help(cmd.getHelp()).setDefault("command", cmd);
        cmd.configureArguments(cp);
    }

    try {
        Namespace options = parser.parseArgs(args);
        Logging.configureLogging(options);
        Runtime rt = Runtime.getRuntime();
        logger.info("Starting LensKit {} on Java {} from {}", LenskitInfo.lenskitVersion(),
                SystemUtils.JAVA_VERSION, SystemUtils.JAVA_VENDOR);
        logger.debug("Built from Git revision {}", LenskitInfo.getHeadRevision());
        logger.debug("Using VM '{}' version {} from {}", SystemUtils.JAVA_VM_NAME, SystemUtils.JAVA_VM_VERSION,
                SystemUtils.JAVA_VM_VENDOR);
        logger.info("Have {} processors and heap limit of {} MiB", rt.availableProcessors(),
                rt.maxMemory() >> 20);
        Command cmd = options.get("command");
        cmd.execute(options);
        logger.info("If you use LensKit in published research, please see http://lenskit.org/research/");
    } catch (ArgumentParserException e) {
        parser.handleError(e);
        System.exit(1);
    } catch (Exception e) {
        logger.error("error running command: " + e, e);
        System.exit(2);
    }
}

From source file:org.lockss.app.LockssDaemon.java

/**
 * Main entry to the daemon.  Startup arguments:
 *
 * -p url1/*from  w w w .  jav a  2  s. com*/
 *     Load properties from url1
 * -p url1 -p url2;url3;url4
 *     Load properties from url1 AND from one of
 *     (url2 | url3 | url4)
 * -g group_name[;group_2;group_3]
 *     Set the daemon groups.  Multiple groups separated by semicolon.
 */
public static void main(String[] args) {
    LockssDaemon daemon;
    if (!SystemUtils.isJavaVersionAtLeast(MIN_JAVA_VERSION)) {
        System.err.println("LOCKSS requires at least Java " + MIN_JAVA_VERSION + ", this is "
                + SystemUtils.JAVA_VERSION + ", exiting.");
        System.exit(Constants.EXIT_CODE_JAVA_VERSION);
    }

    StartupOptions opts = getStartupOptions(args);

    setSystemProperties();

    try {
        daemon = new LockssDaemon(opts.getPropUrls(), opts.getGroupNames());
        daemon.startDaemon();
        // raise priority after starting other threads, so we won't get
        // locked out and fail to exit when told.
        Thread.currentThread().setPriority(Thread.NORM_PRIORITY + 2);

    } catch (ResourceUnavailableException e) {
        log.error("Exiting because required resource is unavailable", e);
        System.exit(Constants.EXIT_CODE_RESOURCE_UNAVAILABLE);
        return; // compiler doesn't know that
                // System.exit() doesn't return
    } catch (Throwable e) {
        log.error("Exception thrown in main loop", e);
        System.exit(Constants.EXIT_CODE_EXCEPTION_IN_MAIN);
        return; // compiler doesn't know that
                // System.exit() doesn't return
    }
    if (CurrentConfig.getBooleanParam(PARAM_APP_EXIT_IMM, DEFAULT_APP_EXIT_IMM)) {
        try {
            daemon.stop();
        } catch (RuntimeException e) {
            // ignore errors stopping daemon
        }
        System.exit(Constants.EXIT_CODE_NORMAL);
    }
    daemon.keepRunning();
    log.info("Exiting because time to die");
    System.exit(Constants.EXIT_CODE_NORMAL);
}

From source file:org.lockss.laaws.mdx.server.LaawsMdxApp.java

public static void main(String[] args) {
    if (LOG.isDebugEnabled())
        LOG.debug("args = " + Arrays.toString(args));

    LaawsMdxApp laawsMdxApp;// w  w w.j  a v a 2  s .  com

    if (!SystemUtils.isJavaVersionAtLeast(MIN_JAVA_VERSION)) {
        System.err.println("LOCKSS requires at least Java " + MIN_JAVA_VERSION + ", this is "
                + SystemUtils.JAVA_VERSION + ", exiting.");
        System.exit(Constants.EXIT_CODE_JAVA_VERSION);
    }

    StartupOptions opts = getStartupOptions(args);
    setSystemProperties();

    try {
        laawsMdxApp = new LaawsMdxApp(opts.getPropUrls(), opts.getGroupNames());
        laawsMdxApp.startDaemon();
        // raise priority after starting other threads, so we won't get
        // locked out and fail to exit when told.
        Thread.currentThread().setPriority(Thread.NORM_PRIORITY + 2);

    } catch (ResourceUnavailableException e) {
        LOG.error("Exiting because required resource is unavailable", e);
        System.exit(Constants.EXIT_CODE_RESOURCE_UNAVAILABLE);
        return; // compiler doesn't know that
                // System.exit() doesn't return
    } catch (Throwable e) {
        LOG.error("Exception thrown in main loop", e);
        System.exit(Constants.EXIT_CODE_EXCEPTION_IN_MAIN);
        return; // compiler doesn't know that
                // System.exit() doesn't return
    }
    if (CurrentConfig.getBooleanParam(PARAM_APP_EXIT_IMM, DEFAULT_APP_EXIT_IMM)) {
        try {
            laawsMdxApp.stop();
        } catch (RuntimeException e) {
            // ignore errors stopping daemon
        }
        System.exit(Constants.EXIT_CODE_NORMAL);
    }
    LOG.info("Done with LaawsMdxApp.main()");
}

From source file:org.yamj.common.model.YamjInfo.java

@SuppressWarnings("rawtypes")
public YamjInfo(Class myClass) {
    // YAMJ Stuff
    this.projectName = myClass.getPackage().getImplementationVendor();
    this.projectVersion = myClass.getPackage().getImplementationVersion();
    this.moduleName = myClass.getPackage().getImplementationTitle();
    this.moduleDescription = myClass.getPackage().getSpecificationTitle();
    if (myClass.getPackage().getSpecificationVendor() != null) {
        this.buildDateTime = DateTimeTools.parseDate(myClass.getPackage().getSpecificationVendor(),
                DateTimeTools.BUILD_FORMAT);
    } else {/*from w w  w.  j a  v a 2 s  .co  m*/
        this.buildDateTime = new DateTime();
    }
    this.buildRevision = myClass.getPackage().getSpecificationVersion();

    // System Stuff
    this.processorCores = Runtime.getRuntime().availableProcessors();
    this.javaVersion = SystemUtils.JAVA_VERSION;
    this.osArch = SystemUtils.OS_ARCH;
    this.osName = SystemUtils.OS_NAME;
    this.osVersion = SystemUtils.OS_VERSION;

    // Times
    this.startUpDateTime = new DateTime(ManagementFactory.getRuntimeMXBean().getStartTime());

    // Counts
    this.counts = new EnumMap<MetaDataType, Long>(MetaDataType.class);

    // IP Address
    this.coreIp = SystemTools.getIpAddress(Boolean.TRUE);

    // Core Port
    this.corePort = 8888; // TODO: Get this from jetty!

    // Database IP & Name
    findDatabaseInfo();

    this.baseArtworkUrl = buildBaseUrl(PropertyTools.getProperty("yamj3.file.storage.artwork", ""));
    this.baseMediainfoUrl = buildBaseUrl(PropertyTools.getProperty("yamj3.file.storage.mediainfo", ""));
    this.basePhotoUrl = buildBaseUrl(PropertyTools.getProperty("yamj3.file.storage.photo", ""));
    this.skinDir = buildBaseUrl(PropertyTools.getProperty("yamj3.file.storage.skins", "./skins/"));
}