如何检索 Java 供应商信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18229784/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 23:33:16  来源:igfitidea点击:

How to retrieve Java vendor information

java

提问by J33nn

How can I retrieve Java vendor information without having to compile and run following script:

如何在无需编译和运行以下脚本的情况下检索 Java 供应商信息:

import java.util.Properties;
public class test
{
    public static void main(String args[])
    {
            Properties prop = System.getProperties();
            System.out.println ("JVM Vendor : " + prop.getProperty("java.vendor") );
    }
}

I couldn't find it in command line options.

我在命令行选项中找不到它。

采纳答案by DB5

Note: The following will work for the Oracle JVM - not tested on others. (To get details on non-standard options execute java -X)

注意:以下内容适用于 Oracle JVM - 未在其他人上测试。(要获取有关非标准选项的详细信息,请执行java -X

You can use the non-standard -XshowSettingsflag to show all settings, or alternatively -XshowSettings:propertiesto show all property settings.

您可以使用非标准-XshowSettings标志来显示所有设置,或者-XshowSettings:properties显示所有属性设置。

So for example if you execute the following command:

例如,如果您执行以下命令:

java -XshowSettings:properties -version

This will show you all properties one of which is java.vendor. Not sure if it is possible to get it to output just a single property though.

这将向您显示所有属性,其中之一是java.vendor. 不确定是否有可能让它只输出一个属性。

回答by Evgeniy Dorofeev

If it's JDK run jvisualvm, open VisualVM app, go to "System properties" tab

如果是 JDK 运行 jvisualvm,打开 VisualVM 应用程序,转到“系统属性”选项卡

回答by xwoker

If you have any running java app 'jinfo' is your friend:

如果您有任何正在运行的 Java 应用程序“jinfo”是您的朋友:

Usage:
jinfo [option] <pid>
    (to connect to running process)
jinfo [option] <executable <core>
    (to connect to a core file)
jinfo [option] [server_id@]<remote server IP or hostname>
    (to connect to remote debug server)

where <option> is one of:
-flag <name>         to print the value of the named VM flag
-flag [+|-]<name>    to enable or disable the named VM flag
-flag <name>=<value> to set the named VM flag to the given value
-flags               to print VM flags
-sysprops            to print Java system properties
<no option>          to print both of the above
-h | -help           to print this help message

So

所以

jinfo -sysprops <pid of javaprocess> | grep "java.vendor = "

gives you the system property.

为您提供系统属性。

Beware:

当心

Also note that the value of system properties can be overwritten! For example, if myProperties.txt contains the following line, the java.vendor system property will be overwritten:

java.vendor=Acme Software Company

还要注意系统属性的值可以被覆盖!例如,如果 myProperties.txt 包含以下行,则 java.vendor 系统属性将被覆盖:

java.vendor=Acme 软件公司

回答by ErezN

if it's Tomcat goto: TOMCAT_HOME/bin/

如果是 Tomcat,请转到:TOMCAT_HOME/bin/

and then execute the version.sh file (*e.g. ./version.sh).

然后执行version.sh文件(*例如./version.sh)。

回答by bj4you

You may use below command

您可以使用以下命令

$ java -XshowSettings:properties -version 

Below is good blog on JAVA properties for Linux and Windows

下面是关于 Linux 和 Windows 的 JAVA 属性的好博客

Retrieve JAVA properties & Version information

检索 JAVA 属性和版本信息