473,396 Members | 2,036 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,396 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 2264
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.