jpype package, could be path problem

Rob Wolfe blue99 at interia.pl
Wed Sep 20 05:53:01 EDT 2006


kelemen.viktor wrote:

> everything worked correctly but when i wrote a short script:
> "
> from jpype import *
>
> 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 tried to run it this's got:
>
> "
> Traceback (most recent call last):
>   File "/home/kelemen/workspace/JPype/src/helloAgent.py", line 3, in ?
>
> jpype.startJVM('/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')
> NameError: name 'jpype' is not defined
> "
>
> What would be the reason?

Consider this:

# bad style (potential name clash)
from jpype import *
startJVM('/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')

# that's better
import jpype
jpype.startJVM('/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')

# for long names of modules
import jpype as jp
jp.startJVM('/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/jre/lib/i386/client/libjvm.so','-ea')

And see this:
http://docs.python.org/tut/node8.html

HTH,
Rob




More information about the Python-list mailing list