简体   繁体   中英

Not able to run java desktop application on Mac OS X Yosemite (10.10)

I have a requirement where I have to run java application(.mpkg) with latest JRE version on Mac OS X Yosemite 10.10. And I have done the following steps.

  1. I have installed the latest JRE from Oracle website.
  2. Set the JAVA_HOME=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/ in ~./bash_profile and also ran shell command source ~./bash_profile
  3. echo $JAVA_HOME is showing /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/
  4. Java -version is providing output java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode) But when I am running the .mpkg/installer I am getting exception pop up saying "To view this web content, you need to install the Java Runtime Environment."

Please suggest answers specific to the JRE.

Little background: Earlier, I had JDK1.6 installed on my Mac OS X Yosemite 10.10 machine. I had to uninstall it because I have to run my application with latest version of JRE. I uninstalled JDK1.6 by following steps:

  1. sudo rm -rf /System/Library/Java/JavaVirtualMachines/1.6.*
  2. sudo rm -rf /Library/Java/JavaVirtualMachine/1.6*
  3. sudo unlink /System/Library/Frameworks/JavaFrameEmbedding.framework/Versions/CurrentJdk

Note: The below points should be read keeping into mind that they are tested with Mac OS X 10.10.2 and Java 7 & 8.

  1. I have observed the behavior of the installations of the JDK/JRE for Java 7 & 8 on Mac OS X 10.10(assuming this should go well with Mac OS X 10.7.3 and later, when Mac OS started supporting java 7 and later).
  2. On a Mac machine, either JRE 7 or JRE 8 can be installed into the default location which is /Library/Internet Plug Ins/JavaAppletPlugin.plugin/.
  3. As we upgrade from JRE 7 to JRE 8, the earlier version gets overridden from the system.
  4. The command java -version wouldn't show any thing until you have installed JDK.
  5. We can have two or more versions of JDK on the same system. They can be found from directory /Library/Java/JavaVirtualMachines/.
  6. By default, the command java -version would always show the latest JDK installer on the system.
  7. As we remove or upgrade the JDK from the system, java -version command shows the results accordingly.
  8. As per my requirements, I never had to set the JAVA_HOME. As I stated above that JRE can be found from the path /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/ and in postscript I initiated my application using command /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
  9. This way, we don't to remove the JDK1.6 from our system. Rather, if we are running our application with just java then make sure correct version of JDK is installed but if we are running our application using the JRE then make sure you provide the full path of the JRE /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM