This is probably a pretty stupid question. I just learned how to use external libraries in java by adding the .jar file to the classpath and whatnot, but where exactly do you keep the .jar file? In a video tutorial about adding .jar files to the classpath, the programmer just kept the .jar file in his downloads folder. So can you put the file anywhere? Or is there a general paradigm as to where you keep your library files that I should abide by?
To include external JAR files, you can either: Copy all the JAR files of the external packages to the Java's Extension Directories (NOT applicable to JDK 9). For Windows, the JDK extension directory is located at " <JAVA_HOME>\jre\lib\ext " (e.g., " c:\Program Files\Java\jdk1.
After you create a Java project, create a new folder by going to File > New > Folder. Call it “lib”. Then import the JAR file into the lib folder by going to File > Import > General > File. Alternatively, you could just copy the JAR file manually into that folder by navigating to it in your workspace.
A JAR file may contain a manifest file, that is located at META-INF/MANIFEST. MF . The entries in the manifest file describe how to use the JAR file. For instance, a Classpath entry can be used to specify other JAR files to load with the JAR.
It is better to use Dependency Management Systems like maven
but if you have restriction for that then,
It's always better to put your jar file inside in your project lib
folder because in migration time it will help you to keep all thing at one place.
In case of multiple project it will be better to have one centralize location on server where you put your jar files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With