Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Clearly the contents of <code>/usr/share/java/</code> don't automatically get added to the classpath - it's just a common location where APT packages put Java libraries. It's up the developer to reference them correctly.</p> <p>JARs in the <code>ext/</code> subdirectory of a Java installation do get added to the classpath automatically. However, <strong>do not</strong> put your own JARs in there. It's a terrible practice because it doesn't match how Java apps are deployed "in the real world".</p> <p>The correct way is using the <code>-cp</code> parameter explicitly <strong>when compiling AND running</strong> your app. Java doesn't compile library code into your <code>.class</code> files, a <code>.class</code> file only refers to names of other classes which are then loaded as-needed from the class path when your app runs. The <code>-cp</code> parameter takes only <code>.jar</code> files, or directories with <code>.class</code> files in them. You can also use wildcards in the value of that parameter. For more information on wrangling the class path, check the <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html" rel="nofollow">tool documentation on setting the class path</a>. </p> <p>You using a build tool that sets it for you automatically, like an IDE or <a href="https://maven.apache.org/" rel="nofollow">Maven</a> or another build system with dependency management. (<a href="http://www.gradle.org/" rel="nofollow">Gradle</a> or <a href="https://ant.apache.org/ivy/" rel="nofollow">Ant+Ivy</a>.) If you're writing a Java app that uses third party libraries, I <em>very strongly</em> suggest you learn and use one of those. (Also, most IDEs can work with Maven's configuration files letting you use the same build settings in a team with people using mixed or no IDEs.) Generally if you're invoking a compiler directly you're not doing it right.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload