简体   繁体   中英

Where to store the downloaded .jar files?

As I am new to Java, I want to ask that where should I put the downloaded .jar files, so that I don't have to use -cp option in javac command to compile it?

For example, suppose I have written a java code "HelloWorld.java" to do a basic input output and I have done import java.io.*; or import java.util.*; , and doing javac HelloWorld.java compile command on it works fine, however, if I have some (for example) import com.mongodb.BasicDBObject; line in my code and it won't compile without me downloading the mongo-java-driver-3.10.2.jar and putting it's location in -cp option of javac . (Like: javac -cp "/home/shivam/Downloads/*" HelloWorld.java ).

So I just want to ask that where should I store the mongo-java-driver-3.10.2.jar file in my computer so that, using just the javac NameOfCode.java command without the -cp option will compile my code successfully?

FYI, I have Ubuntu 18.04.2 and am using Java-11.

Thank you!!

您可以将它们放在JAVA_HOME / lib中,其中JAVA_HOME是jdk设置的路径

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM