Example usage for com.google.common.base StandardSystemProperty JAVA_VM_NAME

List of usage examples for com.google.common.base StandardSystemProperty JAVA_VM_NAME

Introduction

In this page you can find the example usage for com.google.common.base StandardSystemProperty JAVA_VM_NAME.

Prototype

StandardSystemProperty JAVA_VM_NAME

To view the source code for com.google.common.base StandardSystemProperty JAVA_VM_NAME.

Click Source Link

Document

Java Virtual Machine implementation name.

Usage

From source file:org.glowroot.agent.util.AppServerDetection.java

public static boolean isIbmJvm() {
    String vmName = StandardSystemProperty.JAVA_VM_NAME.value();
    return vmName != null && vmName.equals("IBM J9 VM");
}

From source file:org.glowroot.agent.init.ProcessInfoCreator.java

public static ProcessInfo create(String glowrootVersion) {
    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    Long processId = parseProcessId(ManagementFactory.getRuntimeMXBean().getName());
    String jvm = "";
    String javaVmName = StandardSystemProperty.JAVA_VM_NAME.value();
    if (javaVmName != null) {
        jvm = javaVmName + " (" + StandardSystemProperty.JAVA_VM_VERSION.value() + ", "
                + System.getProperty("java.vm.info") + ")";
    }/*ww  w.  ja  v a  2 s. c  o  m*/
    String java = "";
    String javaVersion = StandardSystemProperty.JAVA_VERSION.value();
    if (javaVersion != null) {
        java = "version " + javaVersion + ", vendor " + StandardSystemProperty.JAVA_VM_VENDOR.value();
    }
    String heapDumpPath = getHeapDumpPathFromCommandLine();
    if (heapDumpPath == null) {
        String javaTempDir = MoreObjects.firstNonNull(StandardSystemProperty.JAVA_IO_TMPDIR.value(), ".");
        heapDumpPath = new File(javaTempDir).getAbsolutePath();
    }
    ProcessInfo.Builder builder = ProcessInfo.newBuilder();
    try {
        builder.setHostName(InetAddress.getLocalHost().getHostName());
    } catch (UnknownHostException e) {
        logger.warn(e.getMessage(), e);
    }
    if (processId != null) {
        builder.setProcessId(OptionalInt64.newBuilder().setValue(processId).build());
    }
    return builder.setStartTime(runtimeMXBean.getStartTime()).setJvm(jvm).setJava(java)
            .addAllJvmArg(runtimeMXBean.getInputArguments()).setHeapDumpDefaultDir(heapDumpPath)
            .setGlowrootAgentVersion(glowrootVersion).build();
}

From source file:org.glowroot.agent.init.EnvironmentCreator.java

private static JavaInfo createJavaInfo(String glowrootVersion, JvmConfig jvmConfig,
        RuntimeMXBean runtimeMXBean) {
    String jvm = "";
    String javaVmName = StandardSystemProperty.JAVA_VM_NAME.value();
    if (javaVmName != null) {
        jvm = javaVmName + " (" + StandardSystemProperty.JAVA_VM_VERSION.value() + ", "
                + System.getProperty("java.vm.info") + ")";
    }/*from   w w  w .  j  a v  a 2 s. c  o m*/
    String javaVersion = StandardSystemProperty.JAVA_VERSION.value();
    String heapDumpPath = getHeapDumpPathFromCommandLine();
    if (heapDumpPath == null) {
        String javaTempDir = MoreObjects.firstNonNull(StandardSystemProperty.JAVA_IO_TMPDIR.value(), ".");
        heapDumpPath = new File(javaTempDir).getAbsolutePath();
    }
    return JavaInfo.newBuilder().setVersion(Strings.nullToEmpty(javaVersion)).setVm(jvm)
            .addAllArg(Masking.maskJvmArgs(runtimeMXBean.getInputArguments(), jvmConfig.maskSystemProperties()))
            .setHeapDumpDefaultDir(heapDumpPath).setGlowrootAgentVersion(glowrootVersion).build();
}

From source file:org.killbill.billing.server.updatechecker.ClientInfo.java

public String getJavaVMName() {
    return getProperty(StandardSystemProperty.JAVA_VM_NAME);
}

From source file:edu.buaa.satla.analysis.core.CPAchecker.java

public static String getVersion() {
    return getCPAcheckerVersion() + " (" + StandardSystemProperty.JAVA_VM_NAME.value() + " "
            + StandardSystemProperty.JAVA_VERSION.value() + ")";
}

From source file:org.glowroot.local.ui.JvmJsonService.java

@GET("/backend/jvm/process-info")
String getProcess() throws Exception {
    String command = System.getProperty("sun.java.command");
    String mainClass = null;/*w  ww . j  av a  2 s.co m*/
    List<String> arguments = ImmutableList.of();
    if (command != null) {
        int index = command.indexOf(' ');
        if (index > 0) {
            mainClass = command.substring(0, index);
            arguments = Lists.newArrayList(Splitter.on(' ').split(command.substring(index + 1)));
        }
    }
    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    String jvm = StandardSystemProperty.JAVA_VM_NAME.value() + " ("
            + StandardSystemProperty.JAVA_VM_VERSION.value() + ", " + System.getProperty("java.vm.info") + ")";
    String java = "version " + StandardSystemProperty.JAVA_VERSION.value() + ", vendor "
            + StandardSystemProperty.JAVA_VM_VENDOR.value();
    String javaHome = StandardSystemProperty.JAVA_HOME.value();

    StringBuilder sb = new StringBuilder();
    JsonGenerator jg = mapper.getFactory().createGenerator(CharStreams.asWriter(sb));
    jg.writeStartObject();
    jg.writeNumberField("startTime", runtimeMXBean.getStartTime());
    jg.writeNumberField("uptime", runtimeMXBean.getUptime());
    jg.writeStringField("pid", MoreObjects.firstNonNull(processId, "<unknown>"));
    jg.writeStringField("mainClass", mainClass);
    jg.writeFieldName("mainClassArguments");
    mapper.writeValue(jg, arguments);
    jg.writeStringField("jvm", jvm);
    jg.writeStringField("java", java);
    jg.writeStringField("javaHome", javaHome);
    jg.writeFieldName("jvmArguments");
    mapper.writeValue(jg, runtimeMXBean.getInputArguments());
    jg.writeEndObject();
    jg.close();
    return sb.toString();
}