Accessing JVM from python(从 python 访问 JVM)
问题描述
>>> import boilerpipe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:Anacondalibsite-packagesoilerpipe\__init__.py", line 10, in <module>
jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=%s" % os.pathsep.join(jars))
File "C:Anacondalibsite-packagesjpype\_core.py", line 50, in startJVM
_jpype.startup(jvm, tuple(args), True)
RuntimeError: Unable to load DLL [C:Program FilesJavajre7inclientjvm.dll], error = The specified module could not be found.
at nativecommonincludejp_platform_win32.h:58
试过了:重新安装jvm
Tried: Reinstalling jvm
>> import ctypes
>> import os
>> os.chdir(r"<path to Java bin client folder>")
>> ctypes.CDLL("jvm.dll")
Still unable to fix
尝试下面的代码,仍然卡住:
Tried code below, still stuck:
从 py4j.java_gateway 导入 JavaGateway网关 = JavaGateway()
它给出了与以前相同的错误.
from py4j.java_gateway import JavaGateway
gateway = JavaGateway()
It gives the same error as before.
推荐答案
请检查!
- 给出真实路径(
"C:\Program Files\Java\jre7\binclient\jvm.dll"
) - 检查所有 32 位或 64 位(我的报价始终使用 32 位 Anaconda、JRE7、Python 等)
- 安装pywin32(当然是python2.7.9)
- 授予
jvm.dll
权限(可以运行) - 一切都ok了,试试:
import ctypes
ctypes.CDLL('C:\Program Files\Java\jre7\bin\client\jvm.dll')
- Give a true path (
"C:\Program Files\Java\jre7\binclient\jvm.dll"
) - Check all 32 or 64 bit (my offer always use 32bit Anaconda,JRE7,Python etc.)
- Install pywin32 (of course python2.7.9)
- Give permission to
jvm.dll
(can run) - After all is ok, try:
import ctypes
ctypes.CDLL('C:\Program Files\Java\jre7\bin\client\jvm.dll')
***可能有些java版本的hook不能抛出我用 jre-7u55-windows-i586.exe
***Maybe can't throw the hook of some java versions
i used jre-7u55-windows-i586.exe
希望对您有所帮助!最好的问候!
i hope helpful ! Best regards !
适用于葡萄酒(无错误):
Works on wine(no bug):
这篇关于从 python 访问 JVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 python 访问 JVM


- 如何使用WebFilter实现授权头检查 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01