Vineeth Menon wrote:
Campbell Ritchie wrote:Welcome to the Ranch
Most of the time you are better off not setting a system classpath at all. If somebody has told you to set a system classpath, they are mistaken.
Why is that Campbell??? I thought if we set the class path, we can run the Java code from anywhere within the system, but if we do not set it we have to run from the bin directory where Java is installed right?
If you're just writing small educational programs, and they all live in the same place, and all have the same simple classpath needs, and you don't run any other Java apps, then that's fine. Beyond that though, each project will be in its own location, and have its own set of classes and its own set of 3rd-party libraries, so each one will have different classpath needs. A single, system-wide classpath becomes useless. Each project will typically have a config file and/or startup script that sets the classpath for that app.
And no, you don't need to run from the bin directory where Java is installed, regardless of whether you do or do not set CLASSPATH. You're thinking of PATH, which is separate. It's fine to include Java's bin directory on your PATH.