Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have created a .pkg installer for mac using pkgbuild and product build. Is there a way to bundle java jdk 8 along with the package. Say newer version of java is already installed on Mac and my application is compatible with jdk 8 only. Is there a way that bundled jdk can be put locally for that application ONLY without affecting the newer version of jdk already installed?

You can unzip OpenJDK 8 into a non-system folder (or folder of your application) and use it without affecting other already installed JDKs. There is no need for an installation or modification of global environment variables. Therefore, technically it is not a problem.

Note: Oracle's (not open) JDK has different rules regarding installation and distribution.

If starting your application produces an error:

Error: could not find libjava.dylib Failed to GetJREPath()

This means it uses a JDK native library directly. (See bugs.openjdk.java.net/browse/JDK-8213362 for more information.) In order to solve this either:

  • provide the JRE path like -vm /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home as described in eclipse.org/forums/index.php/t/1102885
  • set $JAVA_HOME in a script for your app.
  • Thanks , I was able to fix the error by modifying path in info.plist Now I get this error Error: could not find libjava.dylib Failed to GetJREPath() Is there a way to fix it without softlinking? Suriya May 3, 2022 at 6:36 This might be an issue with your application or launcher using a native library directly. Something similar is discussed in bugs.openjdk.java.net/browse/JDK-8213362 . Franck May 3, 2022 at 8:21 For Eclipse you can avoid softlinking by providing the JRE path like -vm /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home as described in eclipse.org/forums/index.php/t/1102885 or you could try setting $JAVA_HOME in a script for your app. Franck May 3, 2022 at 15:04 I would appreciate marking the question as solved if the answer is complete from your point of view. It is great to see Java on Mac OS although it will never become a first-class citizen as Steve Jobs once promised. See https://jdeploy.substack.com/p/the-decline-and-fall-of-java-on-the Franck May 5, 2022 at 9:53 I still have a one final query regarding info.plist . Is there a way to embed regex in JRE path. Say a user has a different patch version of java user installed. So hard coding the path would cause run time problems. For example a regex to take any java jdk 8 path not worrying about the patch versions. Suriya May 5, 2022 at 10:39

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question . Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers .