473,385 Members | 1,720 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,385 software developers and data experts.

Can't get compiled jython to work...

Hi. First, I'm not sure if this is the correct group, but becuase I
couldn't find a jython newsgroup, I'll post here.

I'm new to jython and am just trying to get it to work. Interpreted
jython works just fine, but I still can't get my compiled jython to
work.

When I do this:

jythonc fac.py (where fac.py is a jython program), it creates a
jpywork directory with three files fac.java, fac.class, and fac
$_PyInner.class

But if I cd to that directory and do this:

java -classpath $JYTHON_HOME/jython.jar fac

I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: fac
My fac.py looks like this:

def fac(x):
if x <= 1: return 1
return long(x) * fac(x-1)

if __name__ == "__main__":
print 1 + 2
print "Hello" + "Goodbye"
print "fac(3): "
print fac(3)
print "fac(100): "
print fac(100)
Dec 14 '07 #1
1 1478
kramer31 wrote:
Hi. First, I'm not sure if this is the correct group, but becuase I
couldn't find a jython newsgroup, I'll post here.

I'm new to jython and am just trying to get it to work. Interpreted
jython works just fine, but I still can't get my compiled jython to
work.

When I do this:

jythonc fac.py (where fac.py is a jython program), it creates a
jpywork directory with three files fac.java, fac.class, and fac
$_PyInner.class

But if I cd to that directory and do this:

java -classpath $JYTHON_HOME/jython.jar fac

I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: fac
My fac.py looks like this:

def fac(x):
if x <= 1: return 1
return long(x) * fac(x-1)

if __name__ == "__main__":
print 1 + 2
print "Hello" + "Goodbye"
print "fac(3): "
print fac(3)
print "fac(100): "
print fac(100)
Build your jar with the following:

$ jythonc -j fac.jar -a fac.py

Then run it with the following:

$ java -jar fac.jar
3
HelloGoodbye
fac(3):
6
fac(100):
933262154439441526816992388562667004 [...]

Some more hints and suggestions:

1. If you want to generate a java class usable from java, then your module
must obey a few rules: (1) It must be contain one class whose name is the
same as the module name. (2) That class must inherit from some Java class.

2. If you have not already found it, see this page for more information:

http://www.jython.org/docs/jythonc.html

3. jythonc is deprecated, I believe. It is unclear what will happen to it
in the next version of jython. So, maybe you do not want to get too
dependent on it.

Hope this helps.

Dave
--
Dave Kuhlman
http://www.rexx.com/~dkuhlman

Dec 14 '07 #2

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

Similar topics

6
by: Dave Benjamin | last post by:
Hey good people, I've been doing a lot of simultaneous Jython and CPython programming lately, and just wanted to say, with no intended ill will toward any of the individuals who have been...
30
by: monkey | last post by:
Hi all, I am new to programming, already have a glace on introduction of c++, java and finally decided on python. But I found that the .py file is just like the source file, how can I make a...
4
by: Nadeem Mohsin | last post by:
Me and a couple of friends have been thinking of doing something involving Python for our final year undergrad project. We're considering the first idea mentioned on this page:...
6
by: py | last post by:
I want to serialize an object in jython and then be able to read it in using python, and vice versa. Any suggestions on how to do this? pickle doesnt work, nor does using ObjectOutputStream...
2
by: didier.prophete | last post by:
Ok, so I know this is probably a common jython error, but somehow I can't seem to find an answer to this trivial problem. Ok, I have the following (simple) directory structure: $TOP/...
1
by: Mark Fink | last post by:
Hi there, I have a source file FailFixture.py in the folder D:\AUT_TEST\workspace\JyFIT\testutil. Now I want to import the file with "import testutil.FailFixture". Unfortunately I could not...
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: Ant | last post by:
Hi All, I'm looking to provide online python documentation for several jython modules: does anyone know if there are tools to create documentation from docstrings that work in Jython? Jython...
2
by: =?ISO-8859-1?Q?S=E9bastien_Boisg=E9rault?= | last post by:
Frank Wierzbicki and Ted Leung have been hired by Sun. Frank is a key Jython developer and is specifically hired to work full time on Jython, a version of the Python interpreter that runs on top of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.