首页 新闻 会员 周边 捐助

OSError: [Errno 0] JVM DLL not found:

0
悬赏园豆:50 [待解决问题]

[root@centos03 softwore]# python testjmx.py
1 service:jmx:rmi:///jndi/rmi://192.168.223.106:9999/jmxrmi
/u01/java/jdk1.8.0_191/jre/lib/i386/server/libjvm.so
/usr/local/python3/lib/python3.5/site-packages/jpype/_core.py:210: UserWarning:
-------------------------------------------------------------------------------
Deprecated: convertStrings was not specified when starting the JVM. The default
behavior in JPype will be False starting in JPype 0.8. The recommended setting
for new code is convertStrings=False. The legacy value of True was assumed for
this session. If you are a user of an application that reported this warning,
please file a ticket with the developer.
-------------------------------------------------------------------------------

""")
Traceback (most recent call last):
File "testjmx.py", line 18, in <module>
jpype.startJVM(jvmPath)
File "/usr/local/python3/lib/python3.5/site-packages/jpype/_core.py", line 219, in startJVM
_jpype.startup(jvmpath, tuple(args), ignoreUnrecognized, convertStrings)
OSError: [Errno 0] JVM DLL not found: /u01/java/jdk1.8.0_191/jre/lib/i386/server/libjvm.so
at loadLibrary(native/common/include/jp_platform_linux.h:45)
at loadJVM(native/common/jp_env.cpp:179)
at startup(native/python/pyjp_module.cpp:159)

Author: zfh

import jpype,os,time
from jpype import java
from jpype import javax

HOST='192.168.223.106'
PORT=9999
USER=''
PASS=''

URL = "service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi" % (HOST, PORT)
print('1',URL)
jvmPath = jpype.getDefaultJVMPath()
print(jvmPath)

this it the path of your libjvm /usr/lib/jvm/sun-jdk-1.6/jre/lib/amd64/server/libjvm.so on linux

jpype.startJVM("C:\Program Files\Java\jre1.8.0_191\bin\server\jvm.dll")

if not jpype.isJVMStarted():
jpype.startJVM(jvmPath)
jpype.java.lang.System.out.println('Hello world!')

print(jpype.startJVM("C:\Program Files\Java\jre1.8.0_191\bin\server\jvm.dll"))

jhash = java.util.HashMap()
jarray = jpype.JArray(java.lang.String)([USER,PASS])
jhash.put(javax.management.remote.JMXConnector.CREDENTIALS, jarray);
jmxurl = javax.management.remote.JMXServiceURL(URL)
print('2',jmxurl)
jmxsoc = javax.management.remote.JMXConnectorFactory.connect(jmxurl,jhash)
try:
connection = jmxsoc.getMBeanServerConnection();
except Exception as e:
print(e)
print('3',connection)

while True:
time.sleep(5)
object="java.lang:type=Threading"
attribute="ThreadCount"
attr=connection.getAttribute(javax.management.ObjectName(object),attribute)
print('4',attribute, attr)
#
#Memory is a special case the answer is a Treemap in a CompositeDataSupport
object="java.lang:type=Memory"
attribute="HeapMemoryUsage"
attr=connection.getAttribute(javax.management.ObjectName(object),attribute)
print('5',attr.contents.get("used"))
#ceshi
object="kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec"
attribute="Count"
attr=connection.getAttribute(javax.management.ObjectName(object),attribute)
print('6',attribute,attr)

object="java.lang:type=OperatingSystem"
attribute="Version"
attr=connection.getAttribute(javax.management.ObjectName(object),attribute)
print('7',attribute,attr)

object="kafka.server:type=ReplicaManager,name=PartitionCount"
attribute="Value"
attr=connection.getAttribute(javax.management.ObjectName(object),attribute)
print('8',attribute,attr)
乀崋的主页 乀崋 | 初学一级 | 园豆:158
提问于:2019-07-18 22:26
< >
分享
所有回答(2)
0

/u01/java/jdk1.8.0_191/jre/lib/i386/server/libjvm.so 文件不存在或者其依赖的其他文件LD_LIBRARY_PATH需要设置

2012 | 园豆:21645 (高人七级) | 2019-07-19 08:12
0

Java的版本不对。我是64位的操作系统,之前没注意安装了32位的jdk。更换成64位jdk就好了。

乀崋 | 园豆:158 (初学一级) | 2019-07-22 14:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册