Java Learning Note 2, environment variable configuration and common mistakes for beginners

Source: Internet
Author: User

2.1 Configuration of environment variables
2.1.1 The role of the PATH environment variable configuration
the execution of the program requires the use of external instruction Javac, but the javac instruction can only be run in the bin directory under the JDK installation directory, so the program can only be written to the Bin directory program during development, and the source code cannot be written to the JDK's installation directory. Therefore, the source program needs to be saved to the specified directory in any location (English directory), so the JAVAC directive needs to be run in any directory. 2.1.2 Path environment variable configuration mode 1by configuring the PATH environment variable, the directory in which the javac instruction resides, the bin directory under the JDK installation directory, is configured under the PATH variable to allow the javac instruction to run in any directory. WIN7,WIN8 System: Right click on desktop computer → select Properties → select advanced system settings → select advanced tab → Click environment variables → system variables below find path→ double-click PathXP system: Right click on desktop computer → select Properties → select advanced tab → Click environment variables → find path→ in system variable double-click Path to add the bin directory under the JDK installation directory to the leftmost and add a semicolon.
2.1.3 Path environment variable configuration mode 2How to configure the PATH environment variable in reference formCreate a new variable name: Java_homeadd variable values for Java_home: JDK installation directoryModify the JDK directory in the PATH environment variable%java_home%\bin;PATH environment variable has precedence 2.1.4 CLASSPATH environment variable configuration methodCreate a new variable name: The Classpath value is set to the specified directory with the class file, and semicolons are used between multiple directories (;)partitioning: Enables. class files in the Classpath directory to run in any directorytip: You will typically add the configuration to the front of the directory. Configuration, even if the current directory, the. class file search for the current directory, and then based on the order of the directory configuration to find and run, so the configuration in the Classpath directory is in order the difference between 2.1.5 path and ClasspathThe path environment variable is an executable file, such as an. exe file, where the executable file is located in the current path, and if it is not found, go to the path configured in the PATH environment variable to findThe directory where the Java class (. Class) run files are recorded in the CLASSPATH environment variable  2.2 Common errors
1. File extension shadowing causes compilation to fail2. Comment on errors in writing3, the class name format has problems temporarily all use English 4. The curly braces after the class name are not matched correctly5, Main method format errorPublic static void Main (String [] args) {}6. Main method Curly brace missing7. Spelling errors in printed statementsSystem.out.println ("");8, quotation mark use error, use into Chinese full-width quotation mark

Java Learning Note 2, environment variable configuration and common mistakes for beginners

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.