473,320 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Jython run scripts problem (2.2.0a0 on Mac OSX 10.3.8)

I installed darwinports and did a "sudo port install jython"

-------------------------

scott$ which jython
/opt/local/bin/jython

-------------------------

Jython works in interactive mode as shown below:

-------------------------

pyprogs$ cd hotbits/
hotbits$ ls
flips50.py jythoninstall.py randomX randomflip.py
hotbits$ jython
Jython 2.2a0 on java1.4.2_05 (JIT: null)
# Truly random (radioactive decay triggered) coin flip
from randomX import randomHotBits
r = randomHotBits()
if r.nextByte() < 0: .... print 'tails'
.... else:
.... print 'heads'
....
tails

--------------------------

Jython *doesn't* work if I save the above as a script and try to run it.
It refuses to run the script and simply starts up in interactive mode:

---------------------------

hotbits$ jython randomflip.py
Jython 2.2a0 on java1.4.2_05 (JIT: null)


---------------------------

Question:
How can I run scripts as expected (outside interactive mode)?

Thanks in advance.
Jul 19 '05 #1
1 2261
scott wrote:
I installed darwinports and did a "sudo port install jython"

-------------------------

scott$ which jython
/opt/local/bin/jython

-------------------------

Jython works in interactive mode as shown below:

-------------------------

pyprogs$ cd hotbits/
hotbits$ ls
flips50.py jythoninstall.py randomX randomflip.py
hotbits$ jython
Jython 2.2a0 on java1.4.2_05 (JIT: null)
>>> # Truly random (radioactive decay triggered) coin flip
>>> from randomX import randomHotBits
>>> r = randomHotBits()
>>> if r.nextByte() < 0: ... print 'tails'
... else:
... print 'heads'
...
tails

--------------------------

Jython *doesn't* work if I save the above as a script and try to run it.
It refuses to run the script and simply starts up in interactive mode:

---------------------------

hotbits$ jython randomflip.py
Jython 2.2a0 on java1.4.2_05 (JIT: null) >>>


---------------------------

Question:
How can I run scripts as expected (outside interactive mode)?

Thanks in advance.


Looks as if the jython shell script does not pass your scriptname as
argument to the interpreter class.

Mine (on linux) looks like this:

"/usr/lib/j2se/1.4/jre/bin/java" -Dpython.home="/home/deets/lib/jython-2.1"
-classpath "/home/deets/lib/jython-2.1/jython.jar:$CLASSPATH"
"org.python.util.jython" "$@"

Note the "$@" - that passes all additional arguments.

--
Regards,

Diez B. Roggisch
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: rt lange | last post by:
I'm trying to get SciTE to run and compile my jython scripts. This is what I have in my python.properties file: command.name.1.*.py=Go Jython command.1.*.py=jython $(FileNameExt)...
3
by: Dave Benjamin | last post by:
There have been several discussions here about how to write a reload() function that works for classes as well as modules: ...
3
by: Jim Hargrave | last post by:
I've read that it is possible to compile jython to native code using GCJ. PyLucene uses this approach, they then use SWIG to create a Python wrapper around the natively compiled (java) Lucene. Has...
0
by: Maurice LING | last post by:
Hi, I am looking for a way to use Jython in Ant build process. I have some pure Python scripts (not using any C extensions) that I'll like to incorporate into Java using Jython. I heard that...
1
by: techwiz18 | last post by:
Hello, I'm trying to execute a Python script from a Java class using Jython. I'm running into the following error: Exception in thread "main" Traceback (innermost last): File "<string>",...
1
by: Gregor Stich | last post by:
Dear all, I hope my question is here in the right place... What I want to achieve is a communication between Java and Python. We have a pretty strong framework of existing python scripts and...
1
by: nmin | last post by:
Hi. I'm using Jython in combination with Java, webservices and jboss4.0.4. The webservice is implemented in java and creates an PythonInterpreter object which loads the jython scripts. I...
0
by: holdingbe | last post by:
Hi, How to run the jython scripts? I have db_compare.py and jython.bat. I try in command promt Jython,bat db_compare.py output.xml I don't know how to store the output file..
5
by: sarup26 | last post by:
Hello .. I would like to know more about Python and Jython? What is the difference between both of them? What is the future for Jython and which are the areas where it is used? Swot
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.