How to import JavaClass from JPython?

D-Man dsh8290 at rit.edu
Wed Jan 17 19:14:56 EST 2001


First off, JPython is old.  The current version is called Jython
(jython.sourceforge.net).

On Tue, Jan 16, 2001 at 12:05:15AM +0000, Julien Reynier wrote:
| Hi,
| 
| I know how to import core API classes from JPython using for example :
| from java.lang import System
| But I don't know how to import an specific class for example
| MyClass.class that I had developped.
| If I just do the same thing that with core API classes : from my.package
| import MyClass, I obtain an error message.
| 

What is your error message?  "MyClass.class" must be in the class path
otherwise the JVM can't find it.  Jython is just a Java program, after
all.

You import your classes the same way as the system classes:

from package import class

(ie:

from mypackage import MyClass

if your Java looks like:

package mypackge ;
public class MyClass { }
)

Or you can use the fully qualified name:

import mypackage
spam = mypackage.MyClass()


| Is anybody knows if a classpath or other environment variables have to
| be set to specific values ?
| 
| thanks...
| 
| Julien Reynier

HTH,
-D





More information about the Python-list mailing list