jpype package, could be path problem

Rob Wolfe blue99 at interia.pl
Wed Sep 20 07:24:53 EDT 2006


kelemen.viktor wrote:
> Hi
>
> thanks for your suggestions
>
> ive modified the sample code

You've modified it incorrect.

> "
> import jpype
> from jpype import *

You should use "import jpype" OR "from jpype import *" (not
recommended)
but NOT BOTH.

> jpype.startJVM('/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')
> java.lang.System.out.println("hello world")
> shutdownJVM()
> "
>
> and its working. It seems to be quite strange.
> What would be the difference between the two import?

1. "import jpype"

This does not enter the name of the function startJVM defined in jpype
directly in the current symbol table; it only enters the module name
jpype there.
Using the module name you can access the function like that:

jpype.startJVM()

2. "from jpype import"

This enters the name of the function startJVM in the currrent symbol
table,
so you can access the function just like that:

startJVM()

And have you read this: http://docs.python.org/tut/node8.html ?

HTH,
Rob




More information about the Python-list mailing list