java could not open `C | D | E | F: \ jre \ lib \ amd64 \ jvm.cfg 'solutions and reason

Because the installation jdk jre later found to have more than one in the installation directory.
Here Insert Picture Description
Another is automatically installed after the installation of attention is not the same path.
Here Insert Picture Description
Because all I have obsessive-compulsive disorder can not tolerate the existence of two jre directory, so decisively removed under the D disk. Prudent so immediately executed cmd java command, then cool, decisive error!
Here Insert Picture Description
But there is no shortage of javac command error.
Here Insert Picture Description

Why this error will happen, we have configured after installation jdk path variables ah. Delete the jre is not configured path environment variable ah. Environment variables are as follows

C:\Program Files (x86)\Common Files\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;D:\git\cmd;D:\jdk\bin;D:\apache-maven-3.6.1\bin

Obviously configuration D: \ jdk \ bin; let's start with the solution. We just need to configure the D: \ jdk \ bin; environment variable on the left-most in the implementation of java can be.

Note: After configuring the environment variables must close and reopen the CMD command to take effect!

Let's execution result is no problem and our current D drive is no jre directory.
Here Insert Picture Description

The problem is solved? But why is this so? First, we have to restore the environment to a given environment.

1. Which java.exe in the end we performed? Let's take in the end how many java.exe file under windows global search.
Here Insert Picture Description
Actually there have been so many! Then we enter the command line java command which is executed in the end?
  In fact, the software is running is to find the environment variables in the current path to find, can not find and then look at the system environment variables, and system environment variables to find the file in accordance with the order from the front to find the back of the top of a priority the highest level, if found will not find again later. So we just look at our environment variables configuration:

C:\Program Files (x86)\Common Files\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;D:\git\cmd;D:\jdk\bin;D:\apache-maven-3.6.1\bin

The far left is C: \ Program Files (x86) \ Common Files \ Oracle \ Java \ javapath this directory corresponds exactly to the first java.exe we search out. And we own the installed jdk is indeed in the penultimate, there has not been executed. So to solve the problem we need to own jdk path can be configured on the far left .

We know that the implementation of java.exe so it is how to find what jre to execute it?
  When we enter java at the command line. java.exe job is to find the right jre is performed in the following order to find the

  1. First, see if your current directory under jre directory.
  2. Look there is no parent directory jre directory.
  3. There is no registry query jre directory (HKEY_LOCAL_MACHINE \ SOFTWARE \ JavaSoft \ Java Runtime Environment \)
    Here Insert Picture Description
    Here Insert Picture Description
    above two I have not read the current directory and parent directory does not exist then we have to verify Dir three open registration Sure enough, the table was found hidden deep.
    Here Insert Picture Description
    This path is not that I deleted jre directory you! Incidentally, we also found the original jvm jvm virtual machine is a jvm.dll file.

Well this all the mysteries have been solved, the original installation of a jdk there are so many small details! The problem is over! Welcome to explore different views have questions or exchange.

Guess you like

Origin blog.csdn.net/qq_16830879/article/details/90634223