微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法在 Amazon linux

如何解决无法在 Amazon linux

我正在使用 JPype 从我的 Python 测试中调用 Java 代码并通过 Jpype 启动 JVM。

我使用自定义类路径和认 JVM 路径来执行。在错误中它能够找到类路径和认 jvm 路径。

启动JVM时报错

jvmpath = '/usr/lib/jvm/java-1.8.0-amazon-corretto/jre/lib/amd64/server/libjvm.so',classpath = ['/home/jaiadi/test_new/*'],ignoreUnrecognized = False
convertStrings = False

    def startJVM(*args,**kwargs):
        """
        Starts a Java Virtual Machine.  Without options it will start
        the JVM with the default classpath and jvmpath.
    
        The default classpath is determined by ``jpype.getClasspath()``.
        The default jvmpath is determined by ``jpype.getDefaultJVMPath()``.
    
        Parameters:
         *args (Optional,str[]): Arguments to give to the JVM.
            The first argument may be the path the JVM.
    
        Keyword Arguments:
          jvmpath (str):  Path to the jvm library file,Typically one of (``libjvm.so``,``jvm.dll``,...)
            Using None will apply the default jvmpath.
          classpath (str,[str]): Set the classpath for the JVM.
            This will override any classpath supplied in the arguments
            list. A value of None will give no classpath to JVM.
          ignoreUnrecognized (bool): Option to ignore
            invalid JVM arguments. Default is False.
          convertStrings (bool): Option to force Java strings to
            cast to Python strings. This option is to support legacy code
            for which conversion of Python strings was the default. This
            will globally change the behavior of all calls using
            strings,and a value of True is NOT recommended for newly
            developed code.
    
            The default value for this option during 0.7 series is
            True.  The option will be False starting in 0.8. A
            warning will be issued if this option is not specified
            during the transition period.
    
    
        Raises:
          OSError: if the JVM cannot be started or is already running.
          TypeError: if an invalid keyword argument is supplied
            or a keyword argument conflicts with the arguments.
    
         """
        if _jpype.isstarted():
            raise OSError('JVM is already started')
        global _JVM_started
        if _JVM_started:
            raise OSError('JVM cannot be restarted')
    
        args = list(args)
    
        # JVM path
        jvmpath = None
        if args:
            # jvm is the first argument the first argument is a path or None
            if not args[0] or not args[0].startswith('-'):
                jvmpath = args.pop(0)
        if 'jvmpath' in kwargs:
            if jvmpath:
                raise TypeError('jvmpath specified twice')
            jvmpath = kwargs.pop('jvmpath')
        if not jvmpath:
            jvmpath = getDefaultJVMPath()
    
        # Classpath handling
        if _hasClasspath(args):
            # Old style,specified in the arguments
            if 'classpath' in kwargs:
                # Cannot apply both styles,conflict
                raise TypeError('classpath specified twice')
            classpath = None
        elif 'classpath' in kwargs:
            # New style,as a keywork
            classpath = kwargs.pop('classpath')
        else:
            # Not speficied at all,use the default classpath
            classpath = _classpath.getClasspath()
    
        # Handle strings and list of strings.
        if classpath:
            if isinstance(classpath,str):
                args.append('-Djava.class.path=%s' % _handleClasspath([classpath]))
            elif hasattr(classpath,'__iter__'):
                args.append('-Djava.class.path=%s' % _handleClasspath(classpath))
            else:
                raise TypeError("UnkNown class path element")
    
        ignoreUnrecognized = kwargs.pop('ignoreUnrecognized',False)
        convertStrings = kwargs.pop('convertStrings',False)
    
        if kwargs:
            raise TypeError("startJVM() got an unexpected keyword argument '%s'"
                            % (','.join([str(i) for i in kwargs])))
    
        try:
            _jpype.startup(jvmpath,tuple(args),>                          ignoreUnrecognized,convertStrings)
E                          TypeError: function takes exactly 5 arguments (4 given)
jpype/_core.py:212: TypeError
___

我的 JVM 启动代码如下所示

            JAR_CLAsspATH = ['/home/jaiadi/test_new/*']
            jpype.startJVM(jpype.getDefaultJVMPath(),classpath=JAR_CLAsspATH,convertStrings=False)


知道为什么我收到参数错误吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?