[pylucene-dev] finding the JVM DLL on Windows...
vajda at osafoundation.org
Fri Apr 25 17:27:51 PDT 2008
On Fri, 25 Apr 2008, Bill Janssen wrote:
> I'd like to reopen an issue we talked about earlier.
> I'm having difficulties running PyLucene 2.4.0 (JCC 1.9, shared) on
> Windows XP. I've put the "jcc.dll" file into the
> PYTHON/Lib/site-packages/lucene/ directory, which seems to work, but
> it's complaining that "The application has failed to start because
> jvm.dll was not found."
> I think that this is going to be a persistent problem on Windows.
> Even though I have the Java "bin" directory on my path, the jvm.dll is
> in "bin/client", and so is not found.
> What I'd like to do is to have the following prologue inserted into
> the lucene/__init__.py file. It adds the registry's current location
> for jvm.dll to the end of the Path environment variable. This means
> that a location explicitly specified by the user will override this
> default value, but it also means that a location for the dll will
> always be found, and reduce what I expect to be one of the most
> troublesome errors using JCC PyLucene on Windows.
Yes, you have shown that this is possible before. I've also said before that
I'm a little unsure about putting this stuff in for everyone as I'm very
suspicious of registry-based hacks. What works for your setup may not work
for everyone else's setup. Others may then have very strange errors because
there is some 'well hidden' kludge in an __init__.py file messing with
To me, messing with people's PATHs behind their backs very much sounds like
a no-no. Alarm bells go off. If it works for your setup, though, I don't see
any problem with you having this code in a piece of python that runs
_before_ the lucene module is imported. And it would appear to solve the
problem for your setup very well then.
Or am I missing something ?
Are there any actual Windows users (I'm not) on this list (besides Bill)
who have an opinion about this ?
> import sys
> if sys.platform == 'win32':
> # figure out where the jvm.dll is, and make sure that location is on sys.path
> import _winreg as wreg
> registry = wreg.ConnectRegistry(None, wreg.HKEY_LOCAL_MACHINE)
> key = wreg.OpenKey(registry, r"SOFTWARE\JavaSoft\Java Runtime Environment")
> v, t = wreg.QueryValueEx(key, "CurrentVersion")
> key = wreg.OpenKey(registry, r"SOFTWARE\JavaSoft\Java Runtime Environment\%s" % v)
> javahome, t = wreg.QueryValueEx(key, "JavaHome")
> # if we have a javahome, make sure it's on the list
> if javahome:
> import os
> location = os.path.join(javahome, "bin", "client")
> os.environ['Path'] = os.pathsep.join(os.environ['Path'].split(os.pathsep) + [location,])
> pylucene-dev mailing list
> pylucene-dev at osafoundation.org
More information about the pylucene-dev