我是jython的新手。這裏是我嘗試使用javac編譯我的python腳本到類文件失敗的嘗試。Jythonc:如何使用?
[email protected]:~/backyard$ echo "print 'hi'" > test.py
[email protected]:~/backyard$ jython test.py
hi
[email protected]:~/backyard$ jythonc test.py
Warning: jythonc is unmaintained and will not be included in Jython-2.3. See http://jython.org/Project/jythonc.html for alternatives to jythonc. Add '-i' to your invocation of jythonc to turn off this warning
processing test
Required packages:
Creating adapters:
Creating .java files:
test module
Compiling .java to .class...
Compiling with args: ['/usr/bin/javac', '-classpath', '/usr/share/java/jython.jar:/usr/share/java/servlet-api-2.4.jar:/usr/share/java/libreadline-java.jar:./jpywork::/usr/share/jython/Tools/jythonc:/usr/share/jython/Lib:/usr/lib/site-python:__classpath__', './jpywork/test.java']
0
[email protected]:~/backyard$
[email protected]:~/backyard$ cd jpywork/
[email protected]:~/backyard/jpywork$ ls
test.class test.java test$_PyInner.class
[email protected]:~/backyard/jpywork$ java test
Exception in thread "main" java.lang.NoClassDefFoundError: org/python/core/PyObject
Caused by: java.lang.ClassNotFoundException: org.python.core.PyObject
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: test. Program will exit.
[email protected]:~/backyard/jpywork$
請建議正確的方法。
在閱讀jythonc網頁後,我會推薦放棄jythonc(它似乎是他們推薦的) – KevinDTimm 2011-05-31 07:39:04
如果您有'jythonc',那麼您必須運行Jython 2.2。我們在2.5.1,而Jython在最近的幾個版本中有了很大的改進。 – 2011-05-31 08:47:39
是的..我選擇放棄它。 – Nullpoet 2011-05-31 08:58:31