本文整理汇总了Python中jpype.startJVM方法的典型用法代码示例。如果您正苦于以下问题:Python jpype.startJVM方法的具体用法?Python jpype.startJVM怎么用?Python jpype.startJVM使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jpype
的用法示例。
在下文中一共展示了jpype.startJVM方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: query_endpoint
# 需要导入模块: import jpype [as 别名]
# 或者: from jpype import startJVM [as 别名]
def query_endpoint(ctx, host, port, domain):
import jpype
from jpype import java
from jpype import javax
url = "service:jmx:rmi:///jndi/rmi://{}:{}/jmxrmi".format(host, port)
jpype.startJVM(convertStrings=False)
jhash = java.util.HashMap()
jmxurl = javax.management.remote.JMXServiceURL(url)
jmxsoc = javax.management.remote.JMXConnectorFactory.connect(jmxurl, jhash)
connection = jmxsoc.getMBeanServerConnection()
query = javax.management.ObjectName("{}:*".format(domain))
beans = connection.queryMBeans(query, None)
for bean in list(beans):
bean_name = bean.getObjectName().toString()
print("Bean: {}".format(bean_name))
info = connection.getMBeanInfo(javax.management.ObjectName(bean_name))
attrs = info.getAttributes()
for attr in list(attrs):
print(" {:20}: {}".format(str(attr.getName()), attr.getDescription()))
示例2: _start_jvm
# 需要导入模块: import jpype [as 别名]
# 或者: from jpype import startJVM [as 别名]
def _start_jvm(self, additional_flags):
flags = ["-Djava.class.path=" + self._create_classpath()]
if additional_flags:
flags.extend(additional_flags)
jpype.startJVM(jpype.getDefaultJVMPath(), *flags)
示例3: _start_jvm
# 需要导入模块: import jpype [as 别名]
# 或者: from jpype import startJVM [as 别名]
def _start_jvm(self, minimum_heap_size, maximum_heap_size):
jvm_options = [
'-Xms{minimum_heap_size}'.format(minimum_heap_size=minimum_heap_size),
'-Xmx{maximum_heap_size}'.format(maximum_heap_size=maximum_heap_size),
'-Djava.class.path={classpath}'.format(
classpath=self._classpath)
]
if not jpype.isJVMStarted():
jpype.startJVM(
jpype.getDefaultJVMPath(),
*jvm_options
)
示例4: _init_jvm
# 需要导入模块: import jpype [as 别名]
# 或者: from jpype import startJVM [as 别名]
def _init_jvm():
if not jpype.isJVMStarted():
jars = []
for top, dirs, files in os.walk(imp.find_module("twkorean")[1] + "/data/lib"):
for nm in files:
jars.append(os.path.join(top, nm))
jpype.startJVM(jpype.getDefaultJVMPath(),
"-Djava.class.path=%s" % os.pathsep.join(jars))
示例5: connect
# 需要导入模块: import jpype [as 别名]
# 或者: from jpype import startJVM [as 别名]
def connect(self):
self.initConnection()
try:
msg = "what's the location of 'hsqldb.jar'? "
jar = readInput(msg)
checkFile(jar)
args = "-Djava.class.path=%s" % jar
jvm_path = jpype.getDefaultJVMPath()
jpype.startJVM(jvm_path, args)
except Exception, msg:
raise SqlmapConnectionException(msg[0])
示例6: _start_jvm
# 需要导入模块: import jpype [as 别名]
# 或者: from jpype import startJVM [as 别名]
def _start_jvm(self):
"""Start JAVA virtual machine if it is not running."""
jar_location = resource_filename(__name__, 'infodynamics.jar')
if not jp.isJVMStarted():
jp.startJVM(jp.getDefaultJVMPath(), '-ea', ('-Djava.class.path=' +
jar_location))
示例7: _start_jvm
# 需要导入模块: import jpype [as 别名]
# 或者: from jpype import startJVM [as 别名]
def _start_jvm(cls, jvm_path, jvm_options, driver_path, log4j_conf):
if jvm_path is None:
jvm_path = jpype.get_default_jvm_path()
if driver_path is None:
driver_path = os.path.join(cls._BASE_PATH, ATHENA_JAR)
if log4j_conf is None:
log4j_conf = os.path.join(cls._BASE_PATH, LOG4J_PROPERTIES)
if not jpype.isJVMStarted():
_logger.debug("JVM path: %s", jvm_path)
args = [
"-server",
"-Djava.class.path={0}".format(driver_path),
"-Dlog4j.configuration=file:{0}".format(log4j_conf),
]
if jvm_options:
args.extend(jvm_options)
_logger.debug("JVM args: %s", args)
if jpype.__version__.startswith("0.6"):
jpype.startJVM(jvm_path, *args)
else:
jpype.startJVM(
jvm_path, *args, ignoreUnrecognized=True, convertStrings=True
)
cls.class_loader = (
jpype.java.lang.Thread.currentThread().getContextClassLoader()
)
if not jpype.isThreadAttachedToJVM():
jpype.attachThreadToJVM()
if not cls.class_loader:
cls.class_loader = (
jpype.java.lang.Thread.currentThread().getContextClassLoader()
)
class_loader = jpype.java.net.URLClassLoader.newInstance(
[jpype.java.net.URL("jar:file:{0}!/".format(driver_path))],
cls.class_loader,
)
jpype.java.lang.Thread.currentThread().setContextClassLoader(class_loader)