English 中文(简体)
我如何从方案上为某个特定的科索沃信托公司获得系统财产?
原标题:How can I obtain the system properties for a particular JVM instance programmatically?

我愿获得为第三方java进程/JVM设定的系统特性。 我需要在方案上这样做。 例如,获得“java.class.path”财产。 我如何能够这样做?

I know we can get properties for a java program that we write using System.getProperty(). But I need to get the system properties for a third-party JVM. How can I obtain the same?

问题回答

如果由第三方核查和核查机制确定,你仅指另一个核查机制,那么你应尝试jinfo。 这并不涉及所有联合执行监督委员会的实施工作,但很可能有这种或相似之处。 采用一种程序作为理由(或遥控系统,见man jinfo>/em>)。 寻找程序使用jpsjps -v

jinfo 74949
Attaching to process ID 74949, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 20.4-b02-402
Java System Properties:

java.runtime.name = Java(TM) SE Runtime Environment
sun.boot.library.path = /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries
java.vm.version = 20.4-b02-402
awt.nativeDoubleBuffering = true
...

<>0> 从Java 7 <>/strong>开始,你可以使用“指挥系统>jcmd 是JDK 的一部分。 因此,它将以同样的方式对待所有顾问。

它可以与药剂或主类合作。

With the pid of the target JVM

然后是<代码>jcmd${pid} VER.system_properties

<>>Example:

> jcmd 2125 VM.system_properties
2125:
#Tue Jul 24 18:05:39 CEST 2018
sun.desktop=windows
...

With the class name

The syntax is subsequently jcmd${} VER.system_properties

<>>Example:

> jcmd com.mycompany.MyProgram VM.system_properties
2125:
#Tue Jul 24 18:05:39 CEST 2018
sun.desktop=windows
...

http://docs.oracle.com/javase/8/docs/technotes/tools/windows/jcmd.html

See also jcmd Utility

为从方案上获取遥控轨道数据(JVER系统参数、校对统计、梅米信息、GC信息和其他信息),可使用JMX>。 为此,偏远的JV必须允许JMX连接()。 检查如何在遥远的JVER启动JMX。 基本上,你们需要遵循——在遥远的证书中确定具有适当价值的参数:

-Dcom.sun.management.jmxremote.port=1234
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=127.0.0.1

在完成上述工作后,与JMX港口连接,从遥远服务器处获得不同的海洋信息: 以下是一些样本代码:

JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + HOST + ":" + PORT + "/jmxrmi");
JMXConnector jmxConnector = JMXConnectorFactory.connect(url);
MBeanServerConnection mbeanServerConnection = jmxConnector.getMBeanServerConnection();

有了这一<条码>mbeanServerConnection,你可以接触不同管理的豆类,并从数据和元数据交换的豆类获得所需信息。 对于系统特性,您需要获得<代码>RuntimeMXBean bean,并援引getSystemProperties (,以获得所有系统参数。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...