Is there a simple way to specify a path in which to look for extra class files?
Note
I don't mean $CLASSPATH, as far as I can. I'll try and illustrate with an example.
I downloaded the org.json jar from mvnrepo, and took the tree of class files out and put them into `/usr/local/lib/java`, so there's now, e.g. a `/usr/local/lib/java/org/json/JSONArray.class` file. I'm fooling around with this to confirm the API documentation for myself, so I create a `JsonTest.java` file in `/home/me/java`. I can compile this fine, but if I want to run
Of course it doesn't work -- it can't find the org.json stuff. So I set $CLASSPATH to `/usr/local/lib/java`, but this doesn't make any difference. So I try
Which gives me:
Obviously this is not going to work. It's including the arbitrary path in the package names. The only thing I can do is symlink `/usr/local/lib/java/org` into `/home/me/java`. Now everything is fine. But this is a total hassle, esp. if I'm using a VCS across several systems, etc -- I'm potentially going to end up having to include the actual org.json class files like in a jar, separately for every such project, when there's no reason each system can't simply have them installed wherever and let the local compiler and interpreter know where that is.
By comparison, for e.g., a C/C++ compiler I can set a non-standard, not-compiled in path using an environment variable, done. It does not then interpret that path as part of the `#include` spec.
Likewise, for a perl interpreter, I can specify a path for runtime libaries, and it does not expect that packages listed in source scripts be named `package usr::local::lib::perl::foo::bar` -- but it will look for `package foo::bar` in `/usr/local/lib/perl` if that is part of the runtime include path. Same thing with the system linker for native binaries.
What have I misunderstood here? Is this more or less an anti-method with
Java, as in, "Sorry, won't let you do that!"?