2 Java Fundamentals 2

Source: Internet
Author: User

What is the purpose of configuring the PATH environment variable?

The console can find Java development tools in any path.


The current PATH environment variable, in addition to preserving our own configuration of information, there is the system's own information, if you accidentally deleted the PATH environment variable information, it may result in the system part of the function can not be used.

Try to avoid modifying the PATH environment variable information.


The goal is to avoid frequent changes to the PATH environment variable?

Workaround: Create a new environment variable to save the part of the JDK installation directory that will change, and then reference the information saved by the new environment variable on the PATH environment variable.



Requirements: In real-world development Sometimes the JDK version of the information is sometimes used only once or a few times no longer used, then if this is the case, we generally use the SET command to configure temporary environment variables.

Temporary environment variables are only available for the current console window, and once the window is closed, the configured temporary environment variable information disappears.


Use of the SET command:

Set to view all environment variable information.

The name of the SET environment variable to view the specified environment variable information.

Set environment variable name = path information sets the specified environment variable information.

Set environment variable name = Empty the specified environment variable information.

Set environment variable name = new Path;% environment variable name% Add new path information based on the original.


Note: In the future, everyone sees the environment variable information set by the SET command, which is the temporary environment variable information.



The first Hello World example is a common problem:

1. Unable to find the corresponding file

Reason:

1 The suffix name is hidden and your Java file is not a TXT file.

2. The file name was incorrectly written at compile time.


2. The main class Demo1 cannot be found or cannot be loaded

Cause: The class name was incorrectly written at run time. Note: The name of the class file is the corresponding category name. is not the corresponding Java file name.

3. Java code is strictly case-sensitive.

4. ' Javac ' is not an internal or external command

Cause: The PATH environment variable information is not configured or is misconfigured.



CLASSPATH Environment variables:

When the CLASSPATH environment variable is set, when the JVM (Java Virtual machine) is started, then the Java Virtual machine will keep the path information according to the CLASSPATH environment variable.

Find the corresponding class file.


The difference between a semicolon and a semicolon is set for CLASSPATH environment variable information:

1. If the configuration classpath environment variable information does not include a semicolon, then the Java Virtual machine will only search for the corresponding class file in the path saved by Classpath, and will not search the current path down.


2. If you configure the CLASSPATH environment variable information plus a semicolon, the Java Virtual machine will search for the corresponding class file in addition to the path saved by Classpath, if it can find the corresponding class file

Then immediately specify the corresponding class file, otherwise you will go to the current path down search.




Configures the role of classpath: Sets the path information for the class file.


This article from "Small Fish Blog" blog, declined reprint!

2 Java Fundamentals 2

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.