Jpython Question

Tim Hochberg hochberg at psn.net
Fri Jul 23 10:35:29 EDT 1999


Ian Kezsbom wrote in message ...
>Just out of curiosity...lets say I've written a Java program, with many
>classes and I want to run that program through JPython and have access to
>all its classes...how would I go about doing this...


Its almost too easy to describe. I really recomend you just try it out.
However, let's say you have a java class Triangle in the default java
package. After compiling Triangle with your favorite java compiler (e.g.,
javac) you can import the class directly.

# For example
import Triangle
triangle = Triangle()
print  = triangle.area()

More likely, you'd have your java code in a package. If you're java class
triangle is in the package shapes you'd do something like:

from shapes import Triangle
# ....

Note that the java class files must be on your classpath. If the class files
are the current directory, this works automatically. Otherwise you're going
to have to modify the classpath in the jpython launcher (called either
"jpython" or "jpython.bat").

-tim








More information about the Python-list mailing list