Home  >  Article  >  Java  >  What should I do if java prompts that the main class cannot be found or cannot be loaded?

What should I do if java prompts that the main class cannot be found or cannot be loaded?

王林
王林Original
2020-10-20 09:28:25134701browse

Solution to the java prompt that the main class cannot be found or cannot be loaded: 1. Open the advanced system settings and enter the environment variable settings; 2. Create a new JAVA_HOME variable and set the jdk installation path; 3. Edit the PATH variable and add Bin directory path, click [OK].

What should I do if java prompts that the main class cannot be found or cannot be loaded?

#Solution:

Just set the environment variables.

(Recommended tutorial: java course)

Specific method:

Right-click the "Properties" option of "This Computer" on the computer desktop

Select the "Advanced System Settings" option

Click the "Environment Variables" option below

The next step is the specific configuration process:

Click "System Variables" In the "New" option below

fill in "Java_Home"

"Variable value" in the "Variable name" is the JDK installation path. The author's path is "D:\Program Files\Java \jdk1.8.0_91"

Click "OK" option

Find "Path" in "System Variables"

Select "Path" and click "Edit" option

Select "Edit Text" on the right, copy everything in the quotation marks "%Java_Home%\bin;%Java_Home%\jre\bin;" to the front of the "Variable Value" column, and "OK"

In the "System Variables" column, "New", the "Variable Name" is "CLASSPATH", and the "Variable Value" is ".;%Java_Home%\bin;%Java_Home%\lib\dt.jar;%Java_Home %\lib\tools.jar", "OK"

Click the "OK" option at the bottom of "Environment Variables".

Related recommendations:Getting started with java

The above is the detailed content of What should I do if java prompts that the main class cannot be found or cannot be loaded?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn