Getting started with JPype

Ian Clark iclark at mail.ewu.edu
Mon Aug 13 16:45:40 EDT 2007


Disclaimer: I have never used (or even heard of) JPype before...

porter wrote:
(snip)
> 
> "Package myclass.HelloWorld is not Callable"
> 
(snip)
> 
> from jpype import *
> 
> startJVM(getDefaultJVMPath(), "-ea", "-Djava.class.path=D:/tmp/jpype-
> reli/test/dist/test.jar'' )
> 
> package = JPackage("myclass")

Shouldn't this be `package = JPackage("myclasses")` as your Java code is 
contained in the package 'myclasses' not 'myclass'?

> x = package.HelloWorld()

Change this last line to: `x = package.HelloWorld`
(class would be a better name than x IMO)

> x.do_a_message()
> 
> shutdownJVM()

It looks like JPype exports Java classes as members of the object 
referred to by `package`. You then try and call it with () and python 
throws it's hands in the air as it must not be a callable.

Ian




More information about the Python-list mailing list