I am trying to use Neo4j for a project, and want to interface with it through Python since I'm a newbie to programming and don't know any Java. I'm following the installation instructions, but I'm stuck on
the first step, which is to install JPype.
I'm using OS X 10.7 (lion). I think my configuration is pretty standard
with Python 2.7.2 downloaded from the Python website and Java 1.6.0 downloaded from the Apple website.
When I run
% sudo python setup.py install
On the JPype installer, I get about a 100 lines of error code about various .h files, then it
terminates with the lines:
lipo: can't figure out the architecture type of: /var/tmp//
ccwOzLi9.out
error: command 'gcc-4.2' failed with exit status 1
I found a blog post about a gcc error with JPype, but I followed the instructions there to no avail. I also emailed the author of that post, and he told me had never actually used JPype, had been working in OS X 10.6, and didn't have any insight.
I also emailed the creator of JPype, who told me that he only uses Windows, and has no idea how to make the install work on OS X. But if we can solve this, I can point him to the answer and maybe he can add the solution to the JPype documentation and help lots of other people as well!
So, anyone know what I'm doing wrong? I would like to use Neo4j, but I
don't know Java so I'm at a complete loss for how to fix a compiler
error.
Based on reading every Google result available, my two running
theories are that:
I'm somehow using a 32-bit version of Python or of Java (though I
used standard official installations and can't figure out how to
switch to 64-bit or if that's even possible)
The JPype files can only be compiled using GCC 4.0 instead of 4.2.
But I can't find anything online about how to rollback to GCC 4.0 (or
if it comes shipped with 2011 MacBooks and there is some way to force
JPype to compile with that instead).
There is another similar question, but the solution there is to use a different adapter that goes through REST instead of hooking directly into Java. I will try that if I have to, but I would really rather use the recommended Neo4j method if it's possible.
I'm not a Python guy, but tried installing JPype on my machine:
% uname -a
Darwin fatty-i7.local.tld 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64
% java -version
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
On OSX Lion, the latest JDK appears to be located here:
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/JavaVM.framework/
A little googling turned up this post: http://blog.y3xz.com/post/5037243230/installing-jpype-on-mac-os-x
I followed those instructions to modify setup.py, then ran sudo python setup.py install with no problems.
Does that help?
On my Lion, the "include" directory in the JDK was gone, so JPype couldn't find jni.h.
I updated setup.py in two places, one to set where to find jar libraries:
def setupMacOSX(self):
self.javaHome = '/System/Library/Frameworks/JavaVM.framework'
self.jdkInclude = ""
self.libraries = ["dl"]
self.libraryDir = [self.javaHome+"/Home/lib"]
self.macros = [('MACOSX',1)]
And one to set where to find jni.h:
def setupInclusion(self):
self.includeDirs = [
self.javaHome+"/Headers",
<other stuff>
For me,
self.javaHome = '/System/Library/Frameworks/JavaVM.framework/Versions/Current/'
worked.
$ uname -a Darwin 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr 9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64
$ java -version java version "1.6.0_33" Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720) Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)
Here are directions I put in my README to install JPype on OS X 10.7. Same idea as the answers here but different enough to warrant the submission.
The python interface to java (JPype) needs mods to the setup.py:
In summary, you need to make sure the JPype setup.py script can see your Java SDK "Headers" and "Home" directory
I had to install Java from Apple first since my default OS X installation did not come with Headers in the typical Java install path which I found by executing:
/usr/libexec/java_home
If you do happen to have a Headers dir, you probably do not need to reinstall Java and can set the path vars below based on your java HOME directory which is likely different from those in these directions
After I installed Java, I found the new installation in:
/Library/Java/JavaVirtualMachines/
My Home directory was:
/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home/
and my Header directory was:
/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Headers/
1) The JPype script assumes that Headers is within the Home directory but it's not, so I changed the Home path var and created a new Content path var in the setup.py script - In setupMacOSX(self):
self.javaHome = '/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home/'
self.javaContents = '/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/'
2) In setupMacOSX(self), change self.libraryDir:
self.libraryDir = [self.javaContents + "/Libraries"]
Note that this step was mentioned as required but I did not have to do this for it to work so maybe try without it first
3) In setupInclusion, add paths to your "Home/include" dir and your "Headers" dir:
self.javaHome+"/include",
self.javaContents + "/Headers",
4) Running the installation should now work:
sudo python setup.py install
For everyone who is still trying to install Jpype but has meanwhile updated Mac OS: Andreas Kolleger's answer just works fine, but with XCode 4.3 the path changed to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/JavaVM.framework/Versions/Current/
In ML it's MacOSX10.8.sdk. At least on my system. :)
For me, on Mountain Lion
self.javaHome = '/System/Library/Frameworks/JavaVM.framework/'
worked.
$uname -a
Darwin 12.0.0 Darwin Kernel Version 12.0.0: Sun Jun 24 23:00:16 PDT 2012; root:xnu-2050.7.9~1/RELEASE_X86_64 x86_64
$ java -version
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)
I did the same, but choosing
self.javaHome = '/Developer/SDKs/**MacOSX10.6.sdk**/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/'
instead
self.javaHome = '/Developer/SDKs/**MacOSX10.7.sdk**/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/'
realize that I use version 6 vs 7. With the 7 version I got the same errors that the beginning.
To make Will's answer a bit more specific: I had to modify the setupInclusion(self) method by adding the directory path he suggested, ie, '/System/Library/Frameworks/JavaVM.framework/Headers' on Mountain Lion (java version 1.6). With that the installation of JPype succeeded (though gave a bunch of warnings...)
Here's what worked for me - recommend you put the first line in your profile.
export JAVA_HOME=$(/usr/libexec/java_home)
cd $JAVA_HOME
sudo ln -s include Headers
sudo cp include/darwin/* include/
cd -
Note that instead of changing setup.py, I'm changing my JDK install. This has the advantage of fixing the issue for other projects.
For those trying to install on Mountain Lion, I had to further edit the setup.py file to include the header files here:
/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers
Related
so I'm basically trying to run my ionic app on an android device, and the command "ionic cordova run android --device" get as far as telling me an error occurred due to:
Requirements check failed for JDK 1.8.x! Detected version: 16.0.0
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.
So, after verifying which java versions I had and successfully changing the version to a 1.8.X, so when I run java -version, it returns:
java version "1.8.0_251"
However, running "ionic cordova run android --device" again, it returns the same original error:
Requirements check failed for JDK 1.8.x! Detected version: 16.0.0
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.
After some more research, I realized that the javac version of it, tells me another version, and it needs to be same I believe. So when I run "javac -version", I get:
javac 16
So... I couldn't figure out how to change the javac version to be the same as java, the only thing I figure is that it could be something with PATH, but the topics get a bit confusing as I'm not sure what to do next?
I have in my .zshrc file the following:
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
Which I added to fix the original java version issue, but that didn't seem to have changed the javac as well.
So after running the commands "which java" and "which javac" respectively, I get:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
/usr/bin/javac
I assume there's something funny in here, huh? But this is basically where I'm stuck. I'm not even sure if this is the issue, but it's one of those things I think I'm just doing something stupid without realising it lol
Any help is greatly appreciated!
Goal
You are describing that you want "java" and "javac" to both resolve to JDK 1.8. From there, you'll be able to use ionic cordova to do things.
Starting point
Here are various commands you've run, along with their output (I changed format to make it look like actual commands being run, and the output):
Java compiler ("javac") is for JDK 16, and lives at /usr/bin/javac (which might be an alias to another location).
% javac -version
javac 16
% which javac
/usr/bin/javac
Java runtime – the thing which starts the Java Virtual Machine – is resolving somewhere else
altogether – /Library/Internet Plug-Ins/... – and shows up as version 1.8, not 16:
% which java
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
% java -version
java version "1.8.0_251"
A few takeaways..
You have JDK 16 installed, resolving to /usr/bin
You have something separately installed at "/Library/Internet.." – this is most likely a JRE (not a JDK), and is version 1.8
Fix
Install JDK 1.8 – this will give you a compiler and runtime that are both version 1.8
Follow download steps here: https://www.oracle.com/java/technologies/downloads/#java8 Once installed, you should be able to switch to using JDK 1.8, and confirm versions of both the compiler (javac) and the runtime (java) binaries.
There are various ways to set JAVA_HOME and manage multiple JDK installs – this is the simplest way to just get past the issue you're facing: set JAVA_HOME manually. This will be system dependent, but below is an example from my local system.
% export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_341.jdk/Contents/Home
Verify that "java" resolves to your new 1.8 install:
% java -version
java version "1.8.0_341"
Java(TM) SE Runtime Environment (build 1.8.0_341-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.341-b10, mixed mode)
Verify that "javac" also resolves to your new 1.8 install:
% javac -version
javac 1.8.0_341
If you see anything other than above, something else is going on, and we would need to see more details, including whatever output happened from following the above steps.
Posting again since someone moved my question a community where there is not much activity and the solution provided there in the comment did not work.
I have installed Amazon Corretto Java 17 from here.
However, I am not able to switch the Java version to Java 17.
Following are the steps I have already tried:
1.
export JAVA_HOME=$(`/usr/libexec/java_home -v17`)
export JAVA_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home
I have also check the highest version of Java using below command:
/usr/libexec/java_home and it shows correct Java 17 version:
/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home
I have also checked all the versions of Java installed on my machine using command /usr/libexec/java_home -V and it correctly shows Java 8, 11, and 17:
17.0.1 (x86_64) "Amazon.com Inc." - "Amazon Corretto 17" /Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home
11.0.9.1 (x86_64) "Amazon.com Inc." - "Amazon Corretto 11" /Users/harsh.pamnani/Library/Java/JavaVirtualMachines/corretto-11.0.9.1/Contents/Home
1.8.0_275 (x86_64) "Amazon" - "Amazon Corretto 8" /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home
I also added JAVA_HOME exports mentioned in step-1 and step-2 to .zshrc and .bash_profile as well.
I have followed multiple questions on StackOverflow and multiple
blogs as well. For example,
How to set or change the default Java (JDK) version on macOS?
switch java version on mac OS
https://java.tutorials24x7.com/blog/how-to-switch-java-version-on-mac
https://www.lotharschulz.info/2019/08/21/mac-change-default-java-version
https://akrabat.com/using-jenv-to-select-java-version-on-macos/
https://www.happycoders.eu/java/how-to-switch-multiple-java-versions-windows/
I am using jenv to switch between different java versions. Even jenv is not able to find Java 17. I used jenv versions and following is the output:
system
1.8
1.8.0.275
11
11.0
* 11.0.9.1 (set by /Users/harsh.pamnani/.jenv/version)
corretto64-1.8.0.275
corretto64-11.0.9.1
I have also checked that JAVA_HOME is pointing to Java 17. Here is the screenshot: Screenshot
Even after following all the steps above when I do java --version, it is still set to Java 11:
openjdk 11.0.9.1 2020-11-04 LTS
OpenJDK Runtime Environment Corretto-11.0.9.12.1 (build 11.0.9.1+12-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.9.12.1 (build 11.0.9.1+12-LTS, mixed mode)
I have also checked PATH variable, and nothing seems to be relatable to Java. Following is the output for path variables:
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Users/harsh.pamnani/Downloads/apache-maven-3.6.3/bin
Could someone please help me understand if I am missing anything here. Thank you.
which java is often used to find the exact executable you are calling when you type in java.
Keep in mind that when you type in the command java your JAVA_HOME setting is not used. Rather, the operating system PATH setting is used. If you have an older copy of java "before" the one you want to use on the path, then that's what the operating system will give you. To fix a problem like this, you need to alter your path such that the directory of your desired java version comes before any other java versions.
I do see that you checked your PATH setting, but I think you didn't know what to check, because you only listed directories. In those directories, a java executable exists. If the old executable comes in a directory earlier in the path, that's the version of java you will get when running it from the command line, regardless of any other settings.
Now, it is still important to have the JAVA_HOME set correctly, because when various Java tools want to discover items, thy might read JAVA_HOME (and if it is wrong, get directed to a non-matching JVM).
I am having an issue trying to upgrade to Java 8 from Java 6 on my Mac running Mac OS X 10.10.5, with Java 8 seemingly not getting recognized.
I installed Java 8 via the .dmg installer: jre-8u66-macosx-x64.dmg, yet when I enter: java -version, it reports:
java version "1.6.0_65".
Yet, I noticed under the Java Panel via System Preference, the Java Runtime Environment Settings Panel is displaying 1.8.0_102.
From poking around I have noticed:
1) Java 8 seems to have installed into: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk
2) Java 6 seems to have been installed into:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk
I then noticed a post on StackOverflow recommending to use "brew" to install Java, and not use the official installer for Mac, as it is broken. When I went to install brew I got this error message:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
I got this error message: Illegal variable name.
And then I read that "brew" is broken on versions of El Capitan and above.
So, what do I need to do to get this upgrade to Java 8 to work???
Appreciate any help with this! Thanks!
your java command points to the stub binary which uses current version configured
$ ls -la /usr/bin/java
lrwxr-xr-x 1 root wheel 74 Feb 5 2015 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
all you need is to update your JAVA_HOME(I've added that to my ~/.profile):
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
There's a topic which describes this in-depth Need help understanding Oracle's Java on Mac
set your JAVE_HOME to java 8.
For the brew thing, guess you might have run it in csh/tcsh..change it to bash and the script will working to install brew.
I don't know about the brew thing. Looks like you have two jdks and the one with /System/Library/Java/JavaVirtualMachines/1.6.0.jdk has the $PATH set for it but the new one you installed doesn't have its $PATH set for it yet. I would recommend following,
i. either delete the old one and then set the $PATH for new one
ii. just set the $PATH for new one but try to keep both JDK in same location
in both cases you want to have $JAVA_HOME yield the path for your latest jdk which should work.
here is link that might be helpful
https://cloudlink.soasta.com/t5/CloudTest-Knowledge-Base/Adding-JDK-Path-in-Mac-OS-X-Linux-or-Windows/ta-p/43867
for setting the $PATH for you. In plain terms, you have to find a file in your mac that is called .bash_profile and then in that file you have to set the $PATH for your new jdk or which ever jdk you want to work with. This should take little research if you don't know but its not very difficult. Hope this helps..
When I try to start Adobe Flash Builder 4.7, it keeps giving me the following error:
Failed to create the Java Virtual Machine
Before it was working perfectly. The problem started to occur after I set up my MacOSX for a new project. But I didn't change any *.ini file in the Adobe Flash Builder 4.7 installation directory.
I Googled a lot, everyone gave the similar answer: change the *.ini files. I found 3 files:
/Applications/Adobe Flash Builder 4.7.app/Contents/MacOS/Adobe Flash Builder 4.7.ini
/Applications/Adobe Flash Builder 4.7.app/Contents/MacOS/Adobe Flash Builder 4.ini
/Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini
I tried to change the following values as instructed:
-Xms512m
-Xmx1024m
-XX:MaxPermSize=256m
-XX:PermSize=64m
But not working at all. So what values are you guys using if my physical memory is 4GB? (my MacOSX has 4GB memory).
BTW, I did (re)install Java when setting up my MacOSX for a new project, and here is my java info:
[plee#pleemac ~]$ which java
/usr/bin/java
[plee#pleemac ~]$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
[plee#pleemac ~]$
This is ridiculous! But I'm not sure. It seems Adobe Flash Builder 4.7 does NOT support Java 1.7.
After I install Apple's Java 1.6 from:
http://support.apple.com/kb/DL1572?viewlocale=en_US
I am able to open Adobe Flash Builder 4.7.
Hmmm, now I need to install Java 1.7 in a very special way for my new project. Actually I don't know how. But Thank god, I finally could use my Adobe Flash Builder 4.7 again!
I have a solution on Sierra for Flash Builder 4.6:
I'm just set JAVA_HOME environment to java 1.6
install java 1.6 from here: https://support.apple.com/kb/DL1572
from terminal:
cd /Applications/Adobe\ Flash\ Builder\ 4.6/eclipse/Eclipse.app/Contents/MacOS/
export JAVA_HOME="$(/usr/libexec/java_home -v 1.6)"
./eclipse
It works for me.
I was having the same issue. I started eclipse from the terminal (see below) and saw that the JavaVM was complaining about a library from an old version 1.7JDK. When I Looked in /Library/Java/JavaVirtualMachines I saw that after performing updates on the JDK, the old installs (and updates) were still installed. I uninstalled all JDK installation folders except for the most recent. See Oracle site for uninstall instructions (you basically just delete them) http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html
To open Eclipse from terminal, enter: cd /Applications/Adobe\ Flash\ Builder\ 4.7/eclipse/Eclipse.app/Contents/MacOS/
then enter: ./eclipse
I just installed java 1.6 from here: https://support.apple.com/kb/DL1572, and FlashBuilder 4.6 on MacOS Mojave is functional again.
I have to start by saying that I have just switched to Ubuntu from Windows and I am new to Linux in general. Coming from Windows, I really am not familiar with how exactly the permissions work, the Linux file system, where I am able to create folders that I can use without the sudo command etc.
I use eclipse on a daily basis for android development and other simple java swing projects. I was able to download and extract the latest available version of eclipse (kepler) to this path: /opt/eclipse. Inside this directory is the eclipse executable and other eclipse related files.
I also installed the JDK and verified with the java -version command. It says:
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
I am running on a 64 bit CPU architecture so both programs are the 64 bit version.
Now, my problem is that if I open eclipse from the Unity dash or from the file explorer, it give me this error:
However if I run sudo eclipse in the terminal, everything runs just fine as long as I do it as the super user. I have a hunch that the JDK is installed in a folder that is restricted to normal users and only works if I run the sudo command but this is just a hunch. As I said, I am new to Linux and I am not really sure what I am doing wrong here, I am learning as I go. I need a good explanation as to how to make it start from the Unity dock without the sudo command. Thanks in advance!
You'll want to use the chmod command from the terminal to change the permissions on the Java folder. See this link for more information:
http://www.linux.org/threads/file-permissions-chmod.4094/
Well after running the which java cmd, I noticed that the path to the JDK from the eclipse.ini file was not pointing to the correct location. I fixed the path and now it works. I don't know how the sudo cmd overrides the eclipse.ini path to JDK but well, it works