How to set classpath: first click "My Computer"; then select "Properties" and find "Environment Variables" in "Advanced Settings"; then create a new CLASSPATH variable in the system variables inside. .
How to set classpath in Java: Click "My Computer" and select "Properties" to find "Environment Variables" in "Advanced Settings". Create a new CLASSPATH variable in the system variables, where the variable name should be capitalized, and the variable value is the location of java.class
1. Before understanding the CLASSPATH variable, we must first set the two environment variables JAVA_HOME and path to let JAVA The environment can be successfully run before setting the CLASSPATH.
2. Function: After configuring the CLASSPATH environment, the java command searches for class files according to the path in the CLASSPATH variable. You do not need to locate the path where the java.class file is located to run java. class.
3. When the classpath environment is not set, because HelloWorld is not on the C drive, an error will be displayed, saying that the main class cannot be found or cannot be loaded, and the file where it is located must be located before it can be run.
4. After setting the classpath environment, even if java.class is not in the C drive, it can still run as usual, because after configuring the CLASSPATH environment, the java command follows the path in the CLASSPATH variable. Come to find class files.
The virtual machine goes to the CLASSPATH path to find the HelloWorld.class file
5. Configuration method
(1) The previous opening steps are the same as Set the path to the same path, right-click My Computer - Properties - Advanced Settings - Environment Variables
(2) After clicking the environment variables, click New
in the system variables (3 ) fill in as shown in the picture below. Note that the top and bottom are input by yourself. The variable name is in capital letters and the variable value is where java.class is located.
Note: It is CLASSPATH. Do not type the wrong letters
6. If the location of the HelloWorld.class file is changed and it is not under the path E:\Java\jdk-10.0.2, the following situation will occur
That is, the current path cannot be used, but if you want the current path to still be usable, what should you do?
(1) You can double-click the part pointed to under the picture under CLASSPATH
(2) You can add multiple paths. If the current HelloWorld.class is in E:\ If under the Java path, you can
Note: The semicolon in the picture below is half-width, not full-width. Half-width refers to the semicolon in English, and full-width refers to cents in Chinese. No.;
After that, you can run HelloWorld.class normally
The above is the detailed content of How to set classpath in Java. For more information, please follow other related articles on the PHP Chinese website!

The article discusses implementing multi-level caching in Java using Caffeine and Guava Cache to enhance application performance. It covers setup, integration, and performance benefits, along with configuration and eviction policy management best pra

Java's classloading involves loading, linking, and initializing classes using a hierarchical system with Bootstrap, Extension, and Application classloaders. The parent delegation model ensures core classes are loaded first, affecting custom class loa

This article explores integrating functional programming into Java using lambda expressions, Streams API, method references, and Optional. It highlights benefits like improved code readability and maintainability through conciseness and immutability

The article discusses using JPA for object-relational mapping with advanced features like caching and lazy loading. It covers setup, entity mapping, and best practices for optimizing performance while highlighting potential pitfalls.[159 characters]

The article discusses using Maven and Gradle for Java project management, build automation, and dependency resolution, comparing their approaches and optimization strategies.

This article explains Java's NIO API for non-blocking I/O, using Selectors and Channels to handle multiple connections efficiently with a single thread. It details the process, benefits (scalability, performance), and potential pitfalls (complexity,

The article discusses creating and using custom Java libraries (JAR files) with proper versioning and dependency management, using tools like Maven and Gradle.

This article details Java's socket API for network communication, covering client-server setup, data handling, and crucial considerations like resource management, error handling, and security. It also explores performance optimization techniques, i


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools