JPype and classpath (Was Re: embedding jython in CPython... )

Steve Menard foo at bar.com
Sun Jan 23 22:48:27 EST 2005


johng2001 at rediffmail.com wrote:
> Thanks for the response. However, I continue to have problems. Allow me
> to give some more detail.
> 
> For simplicity of testing, I hard coded the classpath and JVM path
> (BTW getDefaultJVMPath() returns None on my system)
> 
> import os, os.path
> from jpype import *
> 
> startJVM("C:/jdk1.5.0/jre/bin/client/jvm.dll",
> "-Djava.class.path=D:/Temp/classes")
> ...
> shutdownJVM()
> 
> 
> I have setup a classes folder in the script folder (D:/Temp) and have
> placed test.class in it.
> I run the script from the script folder (working directory is the same
> as script's root path in this case)
> 
> Now how do I load the class test? I am afraid I cannot make that out
> from the docs.
> 
> The simple test class is
> public class test
> {
> public int i = 100;
> }
> 
> 
> What do I have to do before I can write
> test().i
> ?
> 
> Thank you for your time.
> 

About the getDefaultJVMPath(), could you send me your system 
information? On windows, JPype uses the contents of the registry to find 
the JVM. Of course, the usefulness of this mechanism is limited byt he 
sample of configurations i can test (I have only one machine). So any 
info you can provide me on yours can only help.

About the classpath. JPype 0.4 currently cannot import classes that are 
in the "default" package. The fix is easy, simply put your "test" class 
in a package. For exmaple, if you put the class in the package "test", 
the code to load it would be :

test = jpype.JPackage("test").test


-- 
Steve Menard
--------------------
Maintainer of http://jpype.sourceforge.net



More information about the Python-list mailing list