Environment variables for java installation

后端 未结 14 1023
清歌不尽
清歌不尽 2020-11-22 00:52

How to set the environment variables for Java in Windows (the classpath)?

14条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 01:13

    Keep in mind that the %CLASSPATH% environment variable is ignored when you use java/javac in combination with one of the -cp, -classpath or -jar arguments. It is also ignored in an IDE like Netbeans/Eclipse/IntelliJ/etc. It is only been used when you use java/javac without any of the above mentioned arguments.

    In case of JAR files, the classpath is to be defined as class-path entry in the manifest.mf file. It can be defined semicolon separated and relative to the JAR file's root.

    In case of an IDE, you have the so-called 'build path' which is basically the classpath which is used at both compiletime and runtime. To add external libraries you usually drop the JAR file in a (either precreated by IDE or custom created) lib folder of the project which is added to the project's build path.

提交回复
热议问题