Question about compiling with Jython
Ted Larson Freeman via Jython-users <[email protected]> Sat, 29 Sep 2018 20:13:35 +0000
| Newsgroups | gmane.comp.lang.jython.user |
|---|---|
| Message-ID | <zrPsELWYCjbyAkNY5r2SsrYNsdHD0mCz5ZMTgQ_oTtFmvocAnOhX_wh0xVfWZhU9q338oNg0bZb9nV_jmiQy_wfOdrtV8jbku52iN1mGtfI=@protonmail.com> |
I have just installed Jython 2.7, and am looking for a simple example of compiling a Python script down to a Java .class file. Following a suggestion on Stack Overflow, I tried to compile a file called HelloWorld.py, which contains this:
class HelloWorld(object):
def hello(self):
print 'Hello, World!'
if __name__ == '__main__':
h = HelloWorld()
h.hello()
Using these Jython commands (in the same working directory):
import py_compile
py_compile.compile('HelloWorld.py')
That produces a file called HelloWorld$py.class, but when I try to run it with java from the command line, I get this error:
Error: Could not find or load main class HelloWorld
Please let me know what commands I should use.
Thanks.
Ted
_______________________________________________
Jython-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-users