This article is participating in the Java Theme Month – Java Debug Notes Event, see the event link for details

The problem

I have installed JDK on Mac OS X V10.8, when I update the system to Mac OS X V10.9, I use Java -version in the terminal, the display is as follows:

No Java runtime present, requesting install.
Copy the code

I manually installed JDK 1.7 on my Mac, and the installation seemed to be going well. However, after the installation, I opened the terminal to run Java -version again, and still received the following error message:

No Java runtime present, requesting install.
Copy the code

How can I solve this problem?

answer

Answer 1

For the solution, manually download and install the Java package for OS X from Java for OS X 2017-001

Answer 2

If you just want to install the latest JDK from Oracle, you can download and install it from Oracle, and then configure the JAVA_HOME environment variable in the configuration file from your terminal, as follows:

  • Open a terminal
  • runjava -versionAnd then gives you an error and pop-ups;
  • Download the JDK Java SE – Downloads | Oracle Technology Network | Oracle, and installation;
  • Next, type the following information into the terminal, where the path will change according to your installation location:
export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
Copy the code
  • Then go to the terminal to runjava -version, no error will be reported.

In addition, I have found a new way to write a configuration in your.bashrc configuration file and then use Java permanently on the terminal.

echo export JAVA_HOME=\"/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home\" >> ~/.bashrc
Copy the code

provenance

Installing Java on OS X 10.9 (Mavericks)