0

I had the idea any java application would look up the CLASSPATH variable to check for classes at runtime.

But that does not seem to be the case, as a application I'm running from Eclipse. In which concrete situations is the CLASSPATH variable used, then? How can I make sure Eclipse always makes use of my CLASSPATH variable?

1 Answer 1

1

The CLASSPATH variable is used when the java (or javaw) command is launched without the -classpath or -jar or -cp option. But Eclipse follows best practices, and always uses these options.

IMHO, you should NEVER rely on CLASSPATH. Always specify the classpath explicitely, in the command line options. It's quite rare to want ALL your java programs to share the same libraries. That's why the CLASSPATH global environment variable is a bad idea.

Sign up to request clarification or add additional context in comments.

1 Comment

Interesting. I've never noticed that the CLASSPATH variable was being ignored when setting the -cp option. Thanks. ps: I have also shared your concerns about the CLASSPATH environment variable. I was just curious. It does have its place in some cases, though (for instance, for aspectrt.jar, which will be the same for all the java running programs in your system, at least, most of times).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.