當前位置: 首頁>>代碼示例>>Python>>正文


Python jpype.startJVM方法代碼示例

本文整理匯總了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())) 
開發者ID:DataDog,項目名稱:integrations-core,代碼行數:24,代碼來源:jmx.py

示例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) 
開發者ID:FraBle,項目名稱:python-sutime,代碼行數:7,代碼來源:sutime.py

示例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
            ) 
開發者ID:FraBle,項目名稱:python-duckling,代碼行數:14,代碼來源:duckling.py

示例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)) 
開發者ID:jaepil,項目名稱:twkorean,代碼行數:10,代碼來源:__init__.py

示例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]) 
開發者ID:krintoxi,項目名稱:NoobSec-Toolkit,代碼行數:13,代碼來源:connector.py

示例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)) 
開發者ID:pwollstadt,項目名稱:IDTxl,代碼行數:8,代碼來源:estimators_jidt.py

示例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) 
開發者ID:laughingman7743,項目名稱:PyAthenaJDBC,代碼行數:39,代碼來源:connection.py


注:本文中的jpype.startJVM方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。