[pylucene-dev] two different JCC modules in same VM; initVM()?

Andi Vajda vajda at osafoundation.org
Thu Mar 6 17:05:15 PST 2008


On Thu, 6 Mar 2008, Bill Janssen wrote:

> So, now I've got two different modules that require different
> classpaths, and I'd like to be able to use both in the same Python VM.
> How do I call initVM() appropriately?

That's actually documented line 251 in jcc's README file.
initVM() returns an env value which you can pass on to later initVM() calls.

The code below is supposed to work but has never been tested in a real 
situation:

   >>> import os, foo, bar
   >>> env = foo.initVM(foo.CLASSPATH)
   >>> bar.initVM(classpath=os.pathsep.join([foo.CLASSPATH, bar.CLASSPATH]),
                  env=env)

You can also get this env value by calling getVMEnv() as in:

   >>> import foo
   >>> foo.initVM(foo.CLASSPATH)

   >>> import os, foo, bar
   >>> bar.initVM(classpath=os.pathsep.join([foo.CLASSPATH, bar.CLASSPATH]),
                  env=foo.getVMEnv())

If the classpath resetting doesn't stick, try setting it to both in the 
first initVM() call. I'm a little unsure about the dynamic classpath 
changing of a running VM. I do it in jcc by setting the java.class.path 
system property.

Let me know if this actually works...

Andi..


More information about the pylucene-dev mailing list