Jython: How to use the file “jython-2.7-b1.jar”

2019-02-26 11:47发布

问题:

I am new to Jython. I downloaded a jar file from here http://www.jython.org/downloads.html

Download Jython 2.7beta1 - jython.jar Installer : Standalone version without the bundled python files.

When I run it:

$ java -jar jython-2.7-b1.jar 
Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_33
>>> print "hello"
... 

I didn't get echoed string "hello", instead I got "...".

I guess the point here is what are the "bundled python files" those are missed from this jar.

回答1:

The "bundled python files" are Python standard library modules (such as os.py) found in the Lib folder of a Jython installation.

When running Jython in standalone mode, everything -- including the bundled Python files -- is packaged in a single jar file. The current release for Jython 2.7 is jython-standalone-2.7-b1.jar. When using this jar file, I do not see the strange behaviour shown in the question. The simple print statement works:

$ java -jar jython-standalone-2.7-b1.jar
Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52)
[Java HotSpot(TM) Client VM (Oracle Corporation)] on java1.7.0_03
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello"
hello
>>>

The jython-2.7-b1.jar file is a variant of standalone Jython that does not include the bundled Python files. I don't know why anyone would want to use it. I haven't been able to find any documentation that explains why it is provided as a separate download at http://www.jython.org/downloads.html.



标签: python jython