Java environment variables

Source: Internet
Author: User

The following error occurs during Java compilation on the console:

Exception in thread "Main" Java. Lang. noclassdeffounderror: qpp12_1
Caused by: Java. Lang. classnotfoundexception: qpp12_1
At java.net. urlclassloader $ 1.run( unknown source)
At java. Security. accesscontroller. doprivileged (native method)
At java.net. urlclassloader. findclass (unknown source)
At java. Lang. classloader. loadclass (unknown source)
At sun. Misc. launcher $ appclassloader. loadclass (unknown source)
At java. Lang. classloader. loadclass (unknown source)
Cocould not find the main class: qpp12_1. program will exit.

Solution:

1. Set environment variables.

Right-click my computer> Properties> advanced> environment variables> system variables> path> double-click,

Add a semicolon at the end, and paste the Java installation directory to it. For example:

C:/program files/Java/jdk1.6.0 _ 19/bin

 

Note:

If the PATH variable cannot be found in the "environment variables" window, click "new" in the "System variables" field to create a new one.

 

2. Set classpath

Right-click my computer> Properties> advanced> environment variables> system variables,

Then create a new classpath. The variable value is the directory where your *. Class file is located. My Java file and *. Class are stored in the javaprj directory of drive F.

Therefore, set the value of classpath to F:/javaprj.

 

 

Then you can test it in the console window, enter Java, and press enter to display some detailed information. Everything is OK.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.