我正在尝试在Java中调用python方法,其功能类似于Unresolved import org.python / working with jython and java?
但是,我正在使用ant来编译和运行文件。使用import org.python.util
将给我这个错误
package org.python.util does not exist
我可以看到jython-2.5.0.jar中存在python.org.util。
因此,这是我的build.xml ant文件中包含的类路径:
classpath="${java.class.path}:./jgrapht/lib/jgrapht-jdk1.5.jar:\
./jgrapht/lib/jgraph.jar:./jgraphx/lib/jgraphx.jar:\
./jython/lib/jython-2.5.0.jar:./colt/lib/colt.jar:."
我也将jython jar文件的路径添加到了我的类路径中。即看起来
echo $path
给了我所有必需的路径。这里有我不知道的东西吗?
最佳答案
尝试执行以下操作以使包中的所有类均可用:
import org.python.util.*;
或这包括一个特定的类:
import org.python.util.TemplateAntTask;
编辑:而且,看起来在类路径中jython-2.5.0.jar之后还有一个额外的斜杠。
关于java - 错误包org.python.util不存在,使用ant进行编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9355326/