简体   繁体   中英

How do you pass multiple paths to Java -cp command?

So I am trying to compile a file that imports code from 2+ different .jar files.

The following is the command I am using to compile my file:

javac -cp /home/ugrads/majors/quinnliu/workspace/WalnutiQ/build/libs/WalnutiQ.jar:. HowMARK_II_FitsInToBrainAnatomy.java

Now I am getting an error because I am calling code in another .jar file in another folder but I don't know how to add it correctly to my current -cp command above.

Sample of errors I am getting:

HowMARK_II_FitsInToBrainAnatomy.java:3: error: package com.google.gson does not exist
import com.google.gson.Gson;

Use:

javac -cp jar1.jar;jar2.jar source1.java source2.java ...

On Windows you have to use semicolon to separate the JAR files, but on Unix you can use a colon.

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