简体   繁体   English

-cp选项在JPype中不起作用吗?

[英]Is -cp option not working in JPype?

I am using jpype with Python 2.7 (jpype distribution from the university of california) and I'm trying to use a Java class from a jar file. 我正在将jpype与Python 2.7(来自加利福尼亚大学的jpype发行版)一起使用,并且尝试使用jar文件中的Java类。

It works fine if I start the JVM with 如果我使用以下命令启动JVM,它就可以正常工作

startJVM(getDefaultJVMPath(), "-ea", "-Djava.class.path=D:/jmf.jar")

However, if I am using 但是,如果我正在使用

startJVM(getDefaultJVMPath(), "-ea", "-cp", "D:/jmf.jar")

or 要么

startJVM(getDefaultJVMPath(), "-ea", "-cp D:/jmf.jar")

the classes from that jar are not found... I also tried setting the classpath with 找不到该jar中的类...我也尝试过使用

set CLASSPATH=".;D:\jmf.jar"

which didn't work neither. 这也不起作用。

What is more, using jars which include other jars does not seem to work. 而且,使用包含其他罐子的罐子似乎无效。 Is this a problem with my distribution or is this a general problem with JPype? 这是我发行的问题还是JPype的普遍问题?

JPype doesn't call the java binary directly. JPype不会直接调用Java二进制文件。 It uses the jni libraries. 它使用jni库。 Probably -cp is just a option of the java binary. 可能-cp只是Java二进制文件的一个选项。 The same will probably apply for the CLASSPATH env. 同样的可能适用于CLASSPATH env。

If you want to use more than one jar file or directories in the classpath you can use -Djava.class.path and concatenate the elements with the system's path separator. 如果要在类路径中使用多个jar文件或目录,可以使用-Djava.class.path并将元素与系统的路径分隔符连接起来。 You can use os.path.pathsep.join for that purpose. 为此,可以使用os.path.pathsep.join

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM