Error Installing JPype - Permission Denied after jni.h not found
Question: This is my first post on StackOverflow.

I'm trying to install JPype. I have looked at the tutorials and forums about
this online. However, I am not able to successfully complete the installation.
This is the error I'm getting:

In file included from src/native/common/jp_array.cpp:17:
src/native/common/include/jpype.h:45:10: fatal error: 'jni.h' file not found

I'm running Mac OSX 10.9.3. I will be using a remote server.

EDIT: I managed to get past the jni.h not found error. However, now I have
this error --> error: /Library/Python/2.7/site-packages/_jpype.so: Permission
denied

Below is the setup.py code from JPype

from distutils.core import setup as distSetup, Extension

import os, os.path, sys

class JPypeSetup(object): def **init**(self) : self.extra_compile_args = []
self.macros = []

    
    
    def setupFiles(self) :
        cpp_files = [
                 map(lambda x : "src/native/common/"+x, os.listdir("src/native/common")),
                 map(lambda x : "src/native/python/"+x, os.listdir("src/native/python")),
                 ]
    
        all_src = []
        for i in cpp_files :
            all_src += i
    
        self.cpp = filter(lambda x : x[-4:] == '.cpp', all_src)
        self.objc = filter(lambda x : x[-2:] == '.m', all_src)
    
    
    
    def setupWindows(self):
        print 'Choosing the Windows profile'
        self.javaHome = os.getenv("JAVA_HOME")
        if self.javaHome is None :
            print "environment variable JAVA_HOME must be set"
            sys.exit(-1)
        self.jdkInclude = "win32"
        self.libraries = ["Advapi32"]
        self.libraryDir = [self.javaHome+"/lib"]
        self.macros = [ ("WIN32",1) ]
        self.extra_compile_args = ['/EHsc']
    
    def setupMacOSX(self):
        #self.javaHome = '/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h'
        #self.javaHome = '/System/Library/Frameworks/JavaVM.framework/Versions/'
        self.javaHome = '/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/'
        self.jdkInclude = ""
        self.libraries = ["dl"]
        #self.libraryDir = [self.javaHome+"/System/Library"]
        self.libraryDir = [self.javaHome+"/Libraries"]
        self.macros = [('MACOSX',1)]
    
    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' # Ubuntu linux
            # self.javaHome = '/usr/java/jdk1.5.0_05'    
        self.jdkInclude = "linux"    
        self.libraries = ["dl"]
        self.libraryDir = [self.javaHome+"/lib"]
    
    def setupPlatform(self):
        if sys.platform == 'win32' :
            self.setupWindows()
        elif sys.platform == 'darwin' :
            self.setupMacOSX()
        else:
            self.setupLinux()
    
    def setupInclusion(self):
        self.includeDirs = [
            self.javaHome+"/Headers", 
            self.javaHome+"/Headers/"+self.jdkInclude,
            "src/native/common/include",  
            "src/native/python/include", 
        ]
    
    
    def setup(self):
        self.setupFiles()
        self.setupPlatform()
        self.setupInclusion()
    
        jpypeLib = Extension("_jpype", 
                             self.cpp, 
                             libraries=self.libraries, 
                             define_macros=self.macros, 
                             include_dirs=self.includeDirs, 
                             library_dirs=self.libraryDir,
                             extra_compile_args=self.extra_compile_args
                             )
    
        distSetup( 
            name="JPype", 
            version="0.5.4.2",
            description="Python-Java bridge",
            author="Steve Menard",
            author_email="devilwolf@users.sourceforge.net",
            url="http://jpype.sourceforge.net/",
            packages=[
                "jpype", 'jpype.awt', 'jpype.awt.event', 
                'jpypex', 'jpypex.swing'],
            package_dir={
                "jpype" : "src/python/jpype",
                'jpypex' : 'src/python/jpypex',
            },
    
            ext_modules=[jpypeLib]
        )
    

JPypeSetup().setup()


Answer: I figured out my errors. I just needed to put the sudo command before running
the file. It would look like this --> sudo python setup.py install

As for the jni.h error. Below is the code. This website helped me a lot:
<http://blog.y3xz.com/blog/2011/04/29/installing-jpype-on-mac-os-x>

Here is a copy of the setup.py for mac installation. I changed some code in
these two functions setupMacOSX() and setupInclusion().

    
    
    from distutils.core import setup as distSetup, Extension
    
    import os, os.path, sys
    
    class JPypeSetup(object):
        def __init__(self) :
            self.extra_compile_args = []
            self.macros = []
    
        def setupFiles(self) :
            cpp_files = [
                     map(lambda x : "src/native/common/"+x, os.listdir("src/native/common")),
                     map(lambda x : "src/native/python/"+x, os.listdir("src/native/python")),
                     ]
    
            all_src = []
            for i in cpp_files :
                all_src += i
    
            self.cpp = filter(lambda x : x[-4:] == '.cpp', all_src)
            self.objc = filter(lambda x : x[-2:] == '.m', all_src)
    
    
    
        def setupWindows(self):
            print 'Choosing the Windows profile'
            self.javaHome = os.getenv("JAVA_HOME")
            if self.javaHome is None :
                print "environment variable JAVA_HOME must be set"
                sys.exit(-1)
            self.jdkInclude = "win32"
            self.libraries = ["Advapi32"]
            self.libraryDir = [self.javaHome+"/lib"]
            self.macros = [ ("WIN32",1) ]
            self.extra_compile_args = ['/EHsc']
    
        def setupMacOSX(self):
            #I changed the line below. This is where my JDK root file was located.
            self.javaHome = '/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/'
            self.jdkInclude = ""
            self.libraries = ["dl"]
            #I changed the line below to this:
            self.libraryDir = [self.javaHome+"/Libraries"]
            self.macros = [('MACOSX',1)]
    
        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' # Ubuntu linux
                # self.javaHome = '/usr/java/jdk1.5.0_05'    
            self.jdkInclude = "linux"    
            self.libraries = ["dl"]
            self.libraryDir = [self.javaHome+"/lib"]
    
        def setupPlatform(self):
            if sys.platform == 'win32' :
                self.setupWindows()
            elif sys.platform == 'darwin' :
                self.setupMacOSX()
            else:
                self.setupLinux()
    
        def setupInclusion(self):
            self.includeDirs = [
                #I changed the line below to Headers.
                self.javaHome+"/Headers", 
                #I changed the line below to Headers.
                self.javaHome+"/Headers/"+self.jdkInclude,
                "src/native/common/include",  
                "src/native/python/include", 
            ]
    
    
        def setup(self):
            self.setupFiles()
            self.setupPlatform()
            self.setupInclusion()
    
            jpypeLib = Extension("_jpype", 
                                 self.cpp, 
                                 libraries=self.libraries, 
                                 define_macros=self.macros, 
                                 include_dirs=self.includeDirs, 
                                 library_dirs=self.libraryDir,
                                 extra_compile_args=self.extra_compile_args
                                 )
    
            distSetup( 
                name="JPype", 
                version="0.5.4.2",
                description="Python-Java bridge",
                author="Steve Menard",
                author_email="devilwolf@users.sourceforge.net",
                url="http://jpype.sourceforge.net/",
                packages=[
                    "jpype", 'jpype.awt', 'jpype.awt.event', 
                    'jpypex', 'jpypex.swing'],
                package_dir={
                    "jpype" : "src/python/jpype",
                    'jpypex' : 'src/python/jpypex',
                },
    
                ext_modules=[jpypeLib]
            )
    
    JPypeSetup().setup()
    

