Created
February 23, 2023 00:08
-
-
Save seunboy1/02365582e53e5cde0470a0c61099588d to your computer and use it in GitHub Desktop.
Set up JDK and JNI on MacOs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Follow the steps here | |
https://mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/ | |
or do the following | |
1. Get location of default jdk | |
/usr/libexec/java_home | |
2. Find all installed JDKs | |
/usr/libexec/java_home -V | |
3. Run a specified JDK. Note you can pick any of the versions already in you system | |
/usr/libexec/java_home -v1.8 | |
4. Open the ~/.zshenv | |
nano ~/.zshenv | |
5. Add the following content. Also here you can use any versions | |
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) | |
6. Source the file | |
source ~/.zshenv | |
7. print the $JAVA_HOME | |
echo $JAVA_HOME | |
8. Add this line in the cmakelist above the add jni line | |
set(JAVA_INCLUDE_PATH "$ENV{JAVA_HOME}/include") | |
set(JAVA_AWT_INCLUDE_PATH "$ENV{JAVA_HOME}/include") | |
set(JAVA_INCLUDE_PATH2 "$ENV{JAVA_HOME}/include/darwin") | |
set(JAVA_AWT_LIBRARY "$ENV{JAVA_HOME}/lib/libjawt.dylib") | |
set(JAVA_JVM_LIBRARY "$ENV{JAVA_HOME}/lib/server/libjvm.dylib") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment