Tuesday, November 15, 2011

Thinking about Classpaths..

Let us take a moment to recollect how many different Classpaths we have specified so far:
- A Classpath as a environment variable when we ran javac from a command line
- A Classpath in build.xml which Ant used to build HelloWorld.jar
- A Classpath in MANIFEST.MF which java used to execute the HelloWorld.jar
- A Classpath in Eclipse so it knew how to compile HelloWorld.java
- A Classpath for Ant in Eclipse so it could load Ivy
- A Classpath for Eclipse Run Configuration so it could find HelloWorld.jar

As you can see, Classpath is a ghost that will always follow you in Java(!)
Because every Java program comes with its own ClassLoader which needs a Classpath.

1 comment:

Anonymous said...

We also specified classpaths on the command line (in case the environment variable wasn't set) during compiling and executing the compiled classes.