首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jythonc :如何使用?

Jythonc :如何使用?
EN

Stack Overflow用户
提问于 2011-05-31 15:29:25
回答 2查看 829关注 0票数 0

我是jython的新手。这是我尝试使用javac将我的python脚本编译成类文件的失败。

代码语言:javascript
复制
    rohit@rohit-laptop:~/backyard$ echo "print 'hi'" > test.py
    rohit@rohit-laptop:~/backyard$ jython test.py 
    hi
    rohit@rohit-laptop:~/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  
    rohit@rohit-laptop:~/backyard$ 
    rohit@rohit-laptop:~/backyard$ cd jpywork/
    rohit@rohit-laptop:~/backyard/jpywork$ ls
    test.class  test.java  test$_PyInner.class
    rohit@rohit-laptop:~/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.
    rohit@rohit-laptop:~/backyard/jpywork$

请建议正确的方法。

EN

回答 2

Stack Overflow用户

发布于 2011-06-10 16:20:34

Jython会在第一次执行时自动编译成.class文件,但是如果你想编译它,你可以使用标准库,在Jython lib文件夹中找到py_compile.py或compileall.py。

票数 0
EN

Stack Overflow用户

发布于 2016-05-09 09:57:04

代码语言:javascript
复制
$ java test # is not the exact command to execute the class file 

这个类文件需要jython.jar文件才能执行,您必须在运行时给出jython.jar路径。

代码语言:javascript
复制
#java -cp /home/litindia/jython-2.0.1/jython.jar:. test

-cp是强制的,/home/litindia/jython-2.0.1/jython.jar是我的路径,而jython.jar在我的系统中,你的路径可能会不同。所以请给出合适的路径。

在path之后,:.是强制的。则文件名为必填项。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6184293

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档