Q: Subclassing java with JPython. How?

Henrik Wetterstrom henke at news.bahnhof.se
Wed May 24 00:39:53 CEST 2000


I am evaluating the combination Java av JPython, and since
I am not that experienced in any of the two, I would like some

I am using jpythonc to make a java .class file from a JPython
class. This JPython class inherit from a Java class.

I fail to understand how the subclassed JPython class should be used
from java.

When I look at the java file that jpythonc creates from the
JPython file, every method I would consider to use, have been
made private.

Now consider the following three source files:

--[ Vehicle.java ]-----------------------------

// Java class that will be subclassed by Car.py
public class Vehicle {

  public void printLicenseplate() {


--[ Car.py ]-----------------------------------
# JPython class that will subclass Java Vehicle
import java  
import Vehicle
class Car(Vehicle):
    def start():                               

    def stop():

    def printStatus():
        if x=0:
            print "The car is stopped"
            print "The car is running"

--[ VehicleTest.java ]------------------------
// A Java test class just to test the two classes above
import java.lang.*;
import Vehicle;
import Car;

public class VehicleTest {

   public static void main(String[] args) {
       Car c = new Car();

       // None of these calls to methods in the
       // Car object will be accepted.



I have searched through lots of places for information
about how this should be done without finding a good
answer. Since the output from jpythonc must be useful
somehow, there must be an obvious answer, but I fail to
see it right now.

Any feedback is greatly appreciated.

Henrik W.

More information about the Python-list mailing list