Is -cp option not working in JPype?

依然范特西╮ 提交于 2019-12-25 03:45:06

问题


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.

It works fine if I start the JVM with

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

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?


回答1:


JPype doesn't call the java binary directly. It uses the jni libraries. Probably -cp is just a option of the java binary. The same will probably apply for the 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. You can use os.path.pathsep.join for that purpose.



来源:https://stackoverflow.com/questions/29961327/is-cp-option-not-working-in-jpype

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!