2005年05月23日 星期一 21:47
大家好:
我用jythonc test.py命令生成了test.java文件,但是无法编译,错误如下
C:\jpywork\test.java:1: 软件包 org.python.core 不存在
import org.python.core.*;
^
C:\jpywork\test.java:95: 找不到符号
符号: 类 PyObject
位置: 类 test
public static void moduleDictInit(PyObject dict) {
^
也就是说,在java里要是执行import org.python.core.*;该有什么设置呢?
我已经安装了jython_21.
谢谢.
____________________________________________
DreamMail - 电子邮件新体验 www.dreammail.org
2005年05月24日 星期二 07:24
Dear python-chinese,
因为邮件太多,申请退订。
Yours sincerely,
sun jinjun
2005-05-24
2005年05月24日 星期二 09:53
在jython的目录下,应该有一个\Demo\javaclasses目录,这个例子就是把jython
的文件编译成java,然后再编译成class的完整例子。
按照目录下的readme.txt一步一步地做,一定能成功的。
你遇到的问题就是在编译的时候没有明确指定所需的classpath而产生的。
下面是那个readme文件的内容:
1. run "jython Graph.py" in this directory
This is just to make sure the Jython code works on your machine
2. run "jythonc --package pygraph Graph.py" in this directory
This should produce the Java class pygraph.Graph. Because this is
only a shallow freeze of the code in Graph.py, you can modify the
actual Python code (and any libraries it depends on) without needed
to perform the freeze process again. You will need to repeat this
freeze process any time you add new methods to the Graph class that
override Java methods in its superclass.
Notice the strange "@sig ..." doc comments on the __init__ and the
setExpression methods. These cause convenient methods to be
created on the Java proxy class.
3. run "javac pygraph/PythonGraph.java"
You must have both the current directory ('.') and the Jython
library directory (\jython.jar) in your CLASSPATH for
this to work.
请注意这里说明的设置classpath,如果不好用,就需要直接使用 -cp 参
数来手工指定classpath。
4. run "java pygraph.PythonGraph"
You need the same classpath as given above
On Mon, 23 May 2005 21:47:33 +0800
"163"<acar523 at 163.com> wrote:
=================================================================
> 大家好:
> 我用jythonc test.py命令生成了test.java文件,但是无法编译,错误如下
> C:\jpywork\test.java:1: 软件包 org.python.core 不存在
> import org.python.core.*;
> ^
> C:\jpywork\test.java:95: 找不到符号
> 符号: 类 PyObject
> 位置: 类 test
> public static void moduleDictInit(PyObject dict) {
> ^
> 也就是说,在java里要是执行import org.python.core.*;该有什么设置呢?
> 我已经安装了jython_21.
> 谢谢.
>
> ____________________________________________
> DreamMail - 电子邮件新体验 www.dreammail.org
Zeuux © 2025
京ICP备05028076号