Tuesday, November 8, 2011

Compiling JPype with openjdk-7

JPype is a requirement of neo4j-embedded and is not available through PyPI. When building from source, I ran into the following compile error:

src/native/common/include/jpype.h:45:17: fatal error: jni.h: No such file or directory

First, make sure that you have the JDK installed (sudo apt-get install openjdk-7-jdk if apt-get is available on your machine) and find where jni.h lives (was /usr/lib/jvm/java-7-openjdk-amd64 for me)

Next, make the following change to setup.py in your JPype directory:


def setupLinux(self):
    self.javaHome = os.getenv("JAVA_HOME")
    if self.javaHome is None :
        #self.javaHome = '/usr/lib/jvm/java-1.5.0-sun-1.5.0.08' # was this
        self.javaHome = '/usr/lib/jvm/java-7-openjdk-amd64' # to this
    self.jdkInclude = "linux"
    self.libraries = ["dl"]
    self.libraryDir = [self.javaHome+"/lib"]

Now, your build should complete as expected (barring any other issues local to your own machine).

2 comments:

  1. Thanks, I ran into the very same problem when trying to install neo4j-embedded. Solved. Are you a ne04j developer?

    ReplyDelete
  2. Hey Jaidev, my apologies for such a late reply. No worries, happy it helped someone. No, I'm not a ne04j dev, I was just evaluating it at the time.

    ReplyDelete