当前位置: 首页 > 面试题库 >

众包通用Java系统属性和已知值的完整列表

裘安阳
2023-03-14
问题内容

我目前正在寻找Java系统属性和可能值的完整列表。我正在研究一个简单的类来简化它们的使用(如果您感兴趣,请获取源和背景信息(我的博客))。在本课程中,我尝试提供以下内容:

  • 简单一致地访问Java系统属性(无字符串常量)
  • __可用属性及其可能值的 完整 文档-在我的IDE中(即自动完成,内联Javadoc)
  • 修复返回值和/或命名中的不一致
  • 确保java.io.tmpdir存在–手动地,这就是我执行所有这些操作的主要原因:)

为了获得完整的文档和可用属性的完整列表(甚至包括那些可用性在很大程度上取决于JVM的属性),我希望您下载源代码,运行源代码并发布结果。我将相应地更新该类,并使其在给定位置可用。希望它可以减轻你们中某些人的生活:)

编辑:

我不是在寻找System.getProperties()所描述的标准属性或系统上所有可用的属性。我正在尝试创建系统属性的完整列表-
甚至包括与供应商,jvm或版本相关的那些-不能保证存在并且其文档稀疏或难以找到的那些。属性如

  • sun.desktop(仅限Linux,例如“ gnome”),
  • awt.toolkit(仅限Mac,例如apple.awt.CToolkit)
  • sun.cpu.endian(仅Sun JVM)

我很想让其他人运行我的代码并发布他们的结果,以便以易于使用的Java枚举的形式编译一个综合列表(包含有关属性及其可能值的大量文档),例如:

String file = SystemProperty.JAVA_IO_TMPDIR + "file.txt";

代替

String tmp = System.getProperty("java.io.tmpdir");
if (!tmp.endsWith(File.separator)
    tmp += File.separator;
new File(tmp).mkdirs(); // make sure tmp exists
String file = tmp + "file.txt";

因此,请运行该代码并发布您的发现。这是一个入门的简单脚本:

#!/bin/bash
# download and run
# you should really look at the code first, as you can't be sure
# that I'm a trustworthy guy ;)
wget -N http://techblog.molindo.at/files/SystemProperty.java
javac SystemProperty.java
java SystemProperty

(我知道这不是一个真正的问题,而是一个众包的事情。我希望没人介意)

赏金:

由于此问题没有正确答案,因此赏金将颁发给发现大多数新系统属性的人员。提示:测试非标准JVM(J2ME,Android,GCJ,OpenJDK,Apache
Harmony等)和基于JVM的通用语言(Groovy,Scala,JRuby等)特别有用。

顺便说一句,我计划将最终结果作为Maven工件发布,并在有足够输入后立即将其上传到中央存储库。

更新:最后,公共存储库

作为molindo-
utils项目的一部分,SystemProperty.java现在可以在GitHub上使用。molindo-
utils当前可通过Sonatype的OSS存储库以1.0-SNAPSHOT的形式获得。一旦准备好发布,它也将同步到Maven Central。

<repositories>
  <repository>
    <id>oss.sonatype.org</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
    <releases><enabled>false</enabled></releases>
    <snapshots><enabled>true</enabled></snapshots>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>at.molindo</groupId>
    <artifactId>molindo-utils</artifactId>
    <version>1.0-SNAPSHOT</version>
  </dependency>
</dependencies>

问题答案:

OS AIX 5.3,Java版本:

java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pap32devifx-20090506 (SR9-SSU +PK76176+IZ44410+IZ44495))
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 AIX ppc-32 j9vmap3223ifx-20090225 (JIT enabled)
J9VM - 20090224_30451_bHdSMr
JIT  - 20081112_1511ifx1_r8
GC   - 200811_07)

SystemProperty输出:

FILE_ENCODING: file.encoding=ISO8859-1 (read-only)
FILE_ENCODING_PKG: file.encoding.pkg=null (read-only)
FILE_SEPARATOR: file.separator=/ (read-only)
JAVA_AWT_GRAPHICSENV: java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment (read-only)
JAVA_AWT_PRINTERJOB: java.awt.printerjob=sun.print.PSPrinterJob (read-only)
JAVA_CLASS_PATH: java.class.path=. (read-only)
JAVA_CLASS_VERSION: java.class.version=49.0 (read-only)
JAVA_COMPILER: java.compiler=j9jit23 (read-only)
JAVA_ENDORSED_DIRS: java.endorsed.dirs=null (read-only)
JAVA_EXT_DIRS: java.ext.dirs=/prj/was/java/jre/lib/ext (read-only)
JAVA_HOME: java.home=/prj/was/java/jre (read-only)
JAVA_IO_TMPDIR: java.io.tmpdir=/tmp/
JAVA_LIBRARY_PATH: java.library.path=/prj/was/java/jre/bin:/prj/was/java/jre/bin:/prj/was/java/jre/bin/classic:/prj/was/java/jre/bin:/prj/was/java/jre/bin/j9vm:/usr/lib (read-only)
JAVA_RUNTIME_NAME: java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition (read-only)
JAVA_RUNTIME_VERSION: java.runtime.version=pap32devifx-20090506 (SR9-SSU +PK76176+IZ44410+IZ44495) (read-only)
JAVA_SPECIFICATION_NAME: java.specification.name=Java Platform API Specification (read-only)
JAVA_SPECIFICATION_VENDOR: java.specification.vendor=Sun Microsystems Inc. (read-only)
JAVA_SPECIFICATION_VERSION: java.specification.version=1.5 (read-only)
JAVA_VERSION: java.version=1.5.0 (read-only)
JAVA_VENDOR: java.vendor=IBM Corporation (read-only)
JAVA_VENDOR_URL: java.vendor.url=http://www.ibm.com/ (read-only)
JAVA_VENDOR_URL_BUG: java.vendor.url.bug=null (read-only)
JAVA_VM_INFO: java.vm.info=J2RE 1.5.0 IBM J9 2.3 AIX ppc-32 j9vmap3223ifx-20090225 (JIT enabled)
J9VM - 20090224_30451_bHdSMr
JIT  - 20081112_1511ifx1_r8
GC   - 200811_07 (read-only)
JAVA_VM_NAME: java.vm.name=IBM J9 VM (read-only)
JAVA_VM_SPECIFICATION_NAME: java.vm.specification.name=Java Virtual Machine Specification (read-only)
JAVA_VM_SPECIFICATION_VENDOR: java.vm.specification.vendor=Sun Microsystems Inc. (read-only)
JAVA_VM_SPECIFICATION_VERSION: java.vm.specification.version=1.0 (read-only)
JAVA_VM_VERSION: java.vm.version=2.3 (read-only)
JAVA_VM_VENDOR: java.vm.vendor=IBM Corporation (read-only)
LINE_SEPARATOR: line.separator=
 (read-only)
OS_NAME: os.name=AIX (read-only)
OS_ARCH: os.arch=ppc (read-only)
OS_VERSION: os.version=5.3 (read-only)
PATH_SEPARATOR: path.separator=: (read-only)
SUN_ARCH_DATA_MODEL: sun.arch.data.model=32 (read-only)
SUN_BOOT_CLASS_PATH: sun.boot.class.path=/prj/was/java/jre/lib/vm.jar:/prj/was/java/jre/lib/core.jar:/prj/was/java/jre/lib/charsets.jar:/prj/was/java/jre/lib/graphics.jar:/prj/was/java/jre/lib/security.jar:/prj/was/java/jre/lib/ibmpkcs.jar:/prj/was/java/jre/lib/ibmorb.jar:/prj/was/java/jre/lib/ibmcfw.jar:/prj/was/java/jre/lib/ibmorbapi.jar:/prj/was/java/jre/lib/ibmjcefw.jar:/prj/was/java/jre/lib/ibmjgssprovider.jar:/prj/was/java/jre/lib/ibmjsseprovider2.jar:/prj/was/java/jre/lib/ibmjaaslm.jar:/prj/was/java/jre/lib/ibmcertpathprovider.jar:/prj/was/java/jre/lib/server.jar:/prj/was/java/jre/lib/xml.jar (read-only)
SUN_BOOT_LIBRARY_PATH: sun.boot.library.path=/prj/was/java/jre/bin (read-only)
SUN_CPU_ENDIAN: sun.cpu.endian=null (read-only)
SUN_CPU_ISALIST: sun.cpu.isalist=null (read-only)
SUN_IO_UNICODE_ENCODING: sun.io.unicode.encoding=UnicodeBig (read-only)
SUN_JAVA_LAUNCHER: sun.java.launcher=null (read-only)
SUN_JNU_ENCODING: sun.jnu.encoding=ISO8859-1 (read-only)
SUN_MANAGEMENT_COMPILER: sun.management.compiler=null (read-only)
SUN_OS_PATCH_LEVEL: sun.os.patch.level=null (read-only)
USER_COUNTRY: user.country=US (read-only)
USER_DIR: user.dir=/tmp/avd (read-only)
USER_HOME: user.home=/root (read-only)
USER_LANGUAGE: user.language=en (read-only)
USER_NAME: user.name=root (read-only)
USER_TIMEZONE: user.timezone= (read-only)
USER_VARIANT: user.variant= (read-only)
SUN_DESKTOP: sun.desktop=null (read-only)
USER_ZONEINFO_DIR: user.zoneinfo.dir=null (read-only)
AWT_NATIVE_DOUBLE_BUFFERING: awt.nativeDoubleBuffering=null (read-only)
AWT_TOOLKIT: awt.toolkit=null (read-only)
FTP_NON_PROXY_HOSTS: ftp.nonProxyHosts=null (read-only)
GOPHER_PROXY_SET: gopherProxySet=null (read-only)
HTTP_NON_PROXY_HOSTS: http.nonProxyHosts=null (read-only)
MRJ_VERSION: mrj.version=null (read-only)
SOCKS_NON_PROXY_HOSTS: socksNonProxyHosts=null (read-only)
GNU_CLASSPATH_HOME: gnu.classpath.home=null (read-only)
GNU_CLASSPATH_HOME_URL: gnu.classpath.home.url=null (read-only)
GNU_CLASSPATH_VERSION: gnu.classpath.version=null (read-only)
GNU_CLASSPATH_VM_SHORTNAME: gnu.classpath.vm.shortname=null (read-only)
GNU_CPU_ENDIAN: gnu.cpu.endian=null (read-only)
GNU_GCJ_PRECOMPILED_DB_PATH: gnu.gcj.precompiled.db.path=null (read-only)
GNU_GCJ_PROGNAME: gnu.gcj.progname=null (read-only)
GNU_GCJ_RUNTIME_ENDORSED_DIRS: gnu.gcj.runtime.endorsed.dirs=null (read-only)
GNU_GCJ_USER_REALNAME: gnu.gcj.user.realname=null (read-only)
GNU_JAVA_UTIL_ZONEINFO_DIR: gnu.java.util.zoneinfo.dir=null (read-only)
HTTP_AGENT: http.agent=null (read-only)
JAVA_FULLVERSION: java.fullversion=J2RE 1.5.0 IBM J9 2.3 AIX ppc-32 j9vmap3223ifx-20090225 (JIT enabled)
J9VM - 20090224_30451_bHdSMr
JIT  - 20081112_1511ifx1_r8
GC   - 200811_07 (read-only)
USER_REGION: user.region=null (read-only)
PROGRAM_NAME: program.name=null (read-only)
GROOVY_HOME: groovy.home=null (read-only)
GROOVY_STARTER_CONF: groovy.starter.conf=null (read-only)
JAVA_AWT_HEADLESS: java.awt.headless=false
SUN_AWT_DISABLE_MIXING: sun.awt.disableMixing=null
SUN_AWT_NOERASEBACKGROUND: sun.awt.noerasebackground=null
SUN_AWT_XEMBEDSERVER: sun.awt.xembedserver=null
OS_FAMILY: os.family=unknown (derived)
JAVA_VM_SERVER: java.vm.server=false (derived)


### UNKNOWN
FILE_ENCODING_PKG: file.encoding.pkg=null (read-only)
JAVA_ENDORSED_DIRS: java.endorsed.dirs=null (read-only)
JAVA_VENDOR_URL_BUG: java.vendor.url.bug=null (read-only)
SUN_CPU_ENDIAN: sun.cpu.endian=null (read-only)
SUN_CPU_ISALIST: sun.cpu.isalist=null (read-only)
SUN_JAVA_LAUNCHER: sun.java.launcher=null (read-only)
SUN_MANAGEMENT_COMPILER: sun.management.compiler=null (read-only)
SUN_OS_PATCH_LEVEL: sun.os.patch.level=null (read-only)
SUN_DESKTOP: sun.desktop=null (read-only)
USER_ZONEINFO_DIR: user.zoneinfo.dir=null (read-only)
AWT_NATIVE_DOUBLE_BUFFERING: awt.nativeDoubleBuffering=null (read-only)
AWT_TOOLKIT: awt.toolkit=null (read-only)
FTP_NON_PROXY_HOSTS: ftp.nonProxyHosts=null (read-only)
GOPHER_PROXY_SET: gopherProxySet=null (read-only)
HTTP_NON_PROXY_HOSTS: http.nonProxyHosts=null (read-only)
MRJ_VERSION: mrj.version=null (read-only)
SOCKS_NON_PROXY_HOSTS: socksNonProxyHosts=null (read-only)
GNU_CLASSPATH_HOME: gnu.classpath.home=null (read-only)
GNU_CLASSPATH_HOME_URL: gnu.classpath.home.url=null (read-only)
GNU_CLASSPATH_VERSION: gnu.classpath.version=null (read-only)
GNU_CLASSPATH_VM_SHORTNAME: gnu.classpath.vm.shortname=null (read-only)
GNU_CPU_ENDIAN: gnu.cpu.endian=null (read-only)
GNU_GCJ_PRECOMPILED_DB_PATH: gnu.gcj.precompiled.db.path=null (read-only)
GNU_GCJ_PROGNAME: gnu.gcj.progname=null (read-only)
GNU_GCJ_RUNTIME_ENDORSED_DIRS: gnu.gcj.runtime.endorsed.dirs=null (read-only)
GNU_GCJ_USER_REALNAME: gnu.gcj.user.realname=null (read-only)
GNU_JAVA_UTIL_ZONEINFO_DIR: gnu.java.util.zoneinfo.dir=null (read-only)
HTTP_AGENT: http.agent=null (read-only)
USER_REGION: user.region=null (read-only)
PROGRAM_NAME: program.name=null (read-only)
GROOVY_HOME: groovy.home=null (read-only)
GROOVY_STARTER_CONF: groovy.starter.conf=null (read-only)
JAVA_AWT_HEADLESS: java.awt.headless=false
SUN_AWT_DISABLE_MIXING: sun.awt.disableMixing=null
SUN_AWT_NOERASEBACKGROUND: sun.awt.noerasebackground=null
SUN_AWT_XEMBEDSERVER: sun.awt.xembedserver=null
OS_FAMILY: os.family=unknown (derived)
JAVA_VM_SERVER: java.vm.server=false (derived)


### MISSING
com.ibm.cpu.endian=big
com.ibm.oti.configuration=scar
com.ibm.oti.jcl.build=20081111_1646
com.ibm.oti.vm.bootstrap.library.path=/prj/was/java/jre/bin
com.ibm.oti.vm.library.version=23
com.ibm.util.extralibs.properties=
com.ibm.vm.bitmode=32
ibm.signalhandling.rs=false
ibm.signalhandling.sigchain=true
ibm.signalhandling.sigint=true
ibm.system.encoding=ISO8859-1
invokedviajava=
java.assistive=ON
java.awt.fonts=
java.jcl.version=20090506
java.util.prefs.PreferencesFactory=java.util.prefs.FileSystemPreferencesFactory
jxe.current.romimage.version=9
jxe.lowest.romimage.version=9
sun.java2d.fontpath=


### PLEASE POST FULL OUTPUT AT http://j.mp/props0 or http://j.mp/props1
    /**
     * AIX only: known values: big
     */
    COM_IBM_CPU_ENDIAN("com.ibm.cpu.endian"),
    /**
     * AIX only: known values: scar
     */
    COM_IBM_OTI_CONFIGURATION("com.ibm.oti.configuration"),
    /**
     * AIX only: known values: 20081111_1646
     */
    COM_IBM_OTI_JCL_BUILD("com.ibm.oti.jcl.build"),
    /**
     * AIX only: known values: /prj/was/java/jre/bin
     */
    COM_IBM_OTI_VM_BOOTSTRAP_LIBRARY_PATH("com.ibm.oti.vm.bootstrap.library.path"),
    /**
     * AIX only: known values: 23
     */
    COM_IBM_OTI_VM_LIBRARY_VERSION("com.ibm.oti.vm.library.version"),
    /**
     * AIX only: known values: 
     */
    COM_IBM_UTIL_EXTRALIBS_PROPERTIES("com.ibm.util.extralibs.properties"),
    /**
     * AIX only: known values: 32
     */
    COM_IBM_VM_BITMODE("com.ibm.vm.bitmode"),
    /**
     * AIX only: known values: false
     */
    IBM_SIGNALHANDLING_RS("ibm.signalhandling.rs"),
    /**
     * AIX only: known values: true
     */
    IBM_SIGNALHANDLING_SIGCHAIN("ibm.signalhandling.sigchain"),
    /**
     * AIX only: known values: true
     */
    IBM_SIGNALHANDLING_SIGINT("ibm.signalhandling.sigint"),
    /**
     * AIX only: known values: ISO8859-1
     */
    IBM_SYSTEM_ENCODING("ibm.system.encoding"),
    /**
     * AIX only: known values: 
     */
    INVOKEDVIAJAVA("invokedviajava"),
    /**
     * AIX only: known values: ON
     */
    JAVA_ASSISTIVE("java.assistive"),
    /**
     * AIX only: known values: 
     */
    JAVA_AWT_FONTS("java.awt.fonts"),
    /**
     * AIX only: known values: 20090506
     */
    JAVA_JCL_VERSION("java.jcl.version"),
    /**
     * AIX only: known values: java.util.prefs.FileSystemPreferencesFactory
     */
    JAVA_UTIL_PREFS__PREFERENCES_FACTORY("java.util.prefs.PreferencesFactory"),
    /**
     * AIX only: known values: 9
     */
    JXE_CURRENT_ROMIMAGE_VERSION("jxe.current.romimage.version"),
    /**
     * AIX only: known values: 9
     */
    JXE_LOWEST_ROMIMAGE_VERSION("jxe.lowest.romimage.version"),
    /**
     * AIX only: known values: 
     */
    SUN_JAVA2D_FONTPATH("sun.java2d.fontpath"),


 类似资料:
  • 这三个系统都为应用提供了向用户发送通知的API。 Electron允许开发人员使用HTML5 Notification API快速发送通知,并通过当前系统的自带通知API来显示。 注意: 由于这是一个HTML5 API,因此它仅在渲染器进程中可用 1 let myNotification = new Notification('测试标题', { 2 body: '测试通知' 3 }) 4 ​ 5

  • 问题内容: 在Java中,我们使用System.setProperty()方法来设置一些系统属性。根据本文的介绍,使用系统属性有些棘手。 System.setProperty()可能是一个邪恶的调用。 这是100%线程敌对的 它包含超全局变量 当这些变量在运行时发生神秘变化时,调试非常困难。 我的问题如下。 系统属性的范围如何?它们是针对每个虚拟机专用还是具有“超全局性”,在每个虚拟机实例上共享相

  • 问题内容: JVM中的系统属性System.getProperties()和环境变量System.getenv()有什么区别? 问题答案: 我认为两者之间的区别归结为访问。系统环境变量可以由任何进程访问,而Java系统属性只能由添加到它们的进程访问。 另外,正如Bohemian所说,env变量是在OS中设置的(但是可以通过Java设置),而系统属性则作为命令行选项传递或通过设置setPropert

  • 问题内容: 我正在运行一个具有以下目录结构的简单Java程序: 在Hello.java中,我正在打印“ user.dir”系统属性的值。 我班的已编译文件将存储在文件夹中。 当我从Eclipse运行此类时(右键单击源文件,然后单击Run As-> Java Application),它将打印路径到“ MyProject”文件夹,即在控制台窗口中。 然后,我使用命令窗口运行相同的程序。这是我在窗口上

  • 问题内容: 我有一个运行的现有jar文件。它是Selenium RC服务器。我希望能够更改JVM httpProxy.host/port/etc系统值。一方面,我可以修改源代码并添加此功能。这将需要一些时间。还有另一种可能的方法吗?就像我自己的JAR(将设置这些JVM属性)在同一个JVM实例中调用selenium- rc(这样,它便能够修改其JVM变量的值)? 问题答案: 您可以使用以下命令在命令