简体   繁体   English

为JDK设置CLASSPATH变量

[英]Setting CLASSPATH variable for JDK

In older days, we needed to do following things to run a java program: 在过去,我们需要执行以下操作来运行Java程序:

a. set JAVA_HOME=<Installation directory of jdk>
b. set PATH=%JAVA_HOME%\bin;%PATH%;.
c. set CLASSPATH=%JAVA_HOME%\lib;%CLASSPATH%;.

My queries are: 我的查询是:

  1. Is the step c still needed? 仍然需要步骤c吗?
  2. If the step c is/was done to include the jar files in the JDK lib folder, then how does it actually work? 如果完成了步骤c,以将jar文件包含在JDK lib文件夹中,那么它实际上如何工作? (because normally we need to include the jar file explicitly, for example set CLASSPATH=C:\\files\\afile.jar;%CLASSPATH%;. Simply giving the folder path of jar files does not suffice, how does it suffice here?) (因为通常我们需要显式地包含jar文件,例如set CLASSPATH = C:\\ files \\ afile.jar;%CLASSPATH%;。仅给出jar文件的文件夹路径是不够的,在这里足够了吗?)

You do not need to add the JDK lib directory to the classpath so no, step 3 is not needed. 您不需要将JDK lib目录添加到类路径,因此不需要,不需要步骤3。 The classes in Java's standard library are automatically available to the JVM, you do not need to put them in the classpath explicitly. Java标准库中的类可自动供JVM使用,您无需将它们明确地放在类路径中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM