Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between classpath and build path (in Eclipse)

Is the Eclipse project Properties > Java Build Path > Libraries tab the analog of the java -classpath definitions? What is the difference between a "build path" and a "classpath"?

like image 568
H2ONaCl Avatar asked Dec 06 '22 16:12

H2ONaCl


2 Answers

The classpath is a Java thing. It's a list of either folders or jar files to consider (in order) when resolving classes to be loaded. It's used by the Java JVM. It can be specified by the CLASSPATH environment variable or java -classpath. It's a list of either Jar files or folders separated by a ":" on Linux/OSX systems or ";" on Windows.

The Eclipse build path is a means to construct this Java classpath from artifacts in the Eclipse environment. The Configure Build Path dialog is used to manipulate a file in your project called .classpath (normally hidden). This dialog allows you to form the Java classpath from Jar files, files you have built, folders, external Jar files and other things. It also controls where the Java Development Tooling (JDT) will locate your compiled files, and other things related to class files. The Eclipse help has pretty good documentation on this.

like image 184
Francis Upton IV Avatar answered Mar 03 '23 09:03

Francis Upton IV


The classpath is the place in memory where your Class files and other resources (*.properties, *.xml, among many other types of resources) are made available to the programs running within the JVM.

Eclipse's build path is simply a folder where Eclipse will put the result of whatever 'build' process is set up: this process typically includes the compilation of classes, but it could also include other steps, like code generation, depending on plug-ins that might be installed.

Because you might be running your program from within Eclipse, the build path and the Classpath could possibly contain the same resources. However, keep in mind that the 'build path' is a view of your resources from the Operating System file system perspective, the Classpath is a view of your resources from the Java Virtual Machine perspective.

like image 24
Ytsejammer Avatar answered Mar 03 '23 10:03

Ytsejammer