Jython inherit from Java class

Alan Kennedy alanmk at hotmail.com
Wed Feb 8 10:55:19 EST 2006


[Mark Fink]
> I wrote a Jython class that inherits from a Java class and (thats the
> plan) overrides one method. Everything should stay the same.
>
> If I run this nothing happens whereas if I run the Java class it says:
> usage: java fit.FitServer [-v] host port socketTicket
>         -v      verbose
>
> I think this is because I do not understand the jython mechanism for
> inheritance (yet).

1. Are you running jythonc?

If yes, I think your class and file should have the same name, i.e.
Class FitServer should be in a file called "FitServer.py". I recommend
calling your class something different from the base class, e.g.
MyJythonFitServer, to prevent namespace clashes.

2. If your main function in jython? If yes, please post the code so we
can see how you're instantiating your objects?

3. How are you running this? I.e. show us a command line session which
uses your class.

> JyFitServer.py:
> ===========

> class FitServer(fit.FitServer):
>     # call constructor of superclass
>     def __init__(self, host, port, verbose):
>         FitServer.__init__(self, host, port, verbose)
          ^^^^^^^^^
Shouldn't this be:

>         fit.FitServer.__init__(self, host, port, verbose)

I'm not sure the latter is cause of your problems, but it might be.

HTH,

--
alan kennedy
------------------------------------------------------
email alan:              http://xhaus.com/contact/alan




More information about the Python-list mailing list