Your location:Tech News>News>Script>************ classpath variable ***************

Latest News

************ classpath variable ***************

Author:fsadmin

Views:

  This article describes how to configure the instance variable environment java.Share to you for your reference, as follows:

  Why should configure the environment variables:

  1. PATH environment variable (Window is not case sensitive, the Linux system must be uppercase).

  Role is to specify the command search path

  In the CMD command is executed, it will be specified by the PATH variable to find the path to see if you can find the appropriate command program.We need to jdk installation directory under the bin directory added to the existing PATH variable, bin directory contains executable files often used as javac java javadoc wait, set up after the PATH variable, you can perform in any directory javac java tools such as the.

  Like the path environment variable, which has a% SystemRoot% \ system32 refers to the system root directory system32 directory: lower (C \ Windows \ System32), if it is not set, then you direct CMD> notepad is summoned out Notepad of.

  Test: If you enter direct java javac No, the problem is the PATH settings

  2. CLASSPATH environment variable.

  (1.8 version does not require setting, is said to be automatically added local path, but not because some companies use the latest version of the JDK, set about quite steady)

  Role is to specify the class search path

  To use the already written class, provided of course that can find them, JVM is to find a class by CLASSPATH.We need to install jdk lib subdirectory under the directory dt.jar and tools.jar to the CLASSPATH set, of course, in the current directory. "."Must also be added to the variable. (The current directory: class files compiled Java code exists to put the current directory, the runtime class file must correspond to the directory in the classpath.)

  Test: javac xxx (do not need.class), if you do not set the current directory, even if the jump to the current directory in cmd can not javac to the target file

  3. JAVA_HOME environment variable.

  It points to the installation directory of the jdk, Eclipse / NetBeans / Tomcat software is found by searching JAVA_HOME variable and using the installed jdk.

  In addition, other environmental variables may be provided to obtain the value of the JAVA_HOME environment variable% JAVA_HOME% by conveniently disposed

  PS:

  User Variables with system variables difference:

  The difference between each user and system variables used by the current user only common variable.

  Variable settings:

  ************ classpath variable ***************

  Open My Computer - Properties - Advanced - Environment Variables

  

  ***************************************

  2.

  New variable

  

  JAVA_HOME

  

  Variable name is the path where the JDK is installed;

  ***************************************

  3.New variable

  CLASSPATH / classpath (two variable name can)

  

  variable:.;% JAVA_HOME% \ lib \ dt.jar;% JAVA_HOME% \ lib \ tools.jar;

  meaning:

  ·% JAVA_HOME% ----- achieve the JAVA_HOME variable value, the% JAVA_HOME% \ lib \ dt.jar;% JAVA_HOME% \ lib \ tools.JAR; means lib \ dt installation path in the JDK.jar and \ lib \ tools.jar

  · Lib \ dt.jar and \ lib \ tools.jar

  dt.jar and tools.two java jar is the most basic package, which contains a package from the most important lang java to advanced features such as visualization of the swing package, is essential for java.

  tools.jar is used to compile the system when a class used, i.e., when used to perform javac

  · Rt.jar is JAVA basis Class (default loading path, not necessary to add the default), dt.jar is a library on the operating environment (mainly Swing), tools.jar is a tool library

  ************* path variable ******************

  The path which is below the bin java executable compiler and its tools, such as java, javadoc, etc., you are in any folder by typing in cmd run javac, the system will automatically summoned the java compiler is attributed to the environment variable settings

  Value Select the "Environment Variables" in the variable named "Path" environment variable, double-click the variables, JDK installation path absolute path bin directory (full write path), added to the Path variables.

  or:

  % JAVA_HOME% \ bin;% JAVA_HOME% \ jre \ bin;

  Jre plus is used for non-compiler to run the program

  !!!Do not delete the wrong things, press Cancel to delete it and try to.

  

  ***********************************

  path environment variable to the success of the test: Run CMD, enter java -version

  

  More java content and interested readers can view the site topic: "Java object-oriented programming introductory and advanced tutorials", "Java data structures and algorithms tutorial", "Java DOM node operating skills summary", "Java files Contents summary operating skills "and" Java cache operation tips summary "

  In this paper, we hope the java programming help.

  You may also be interested in the article: Win10 Java jdk14.0.2 installation and environment variable configuration detailed tutorial Java method for configuring a java environment variables under win10 environment variables of Graphical win10 configuration win10 the java (JDK installation) environment variables configurations and related win10 disposed java environment variable method win10 operating system to restart the computer java environment variable failure

Recommend article

Relate article