简体   繁体   中英

How to use a jar file in conjunction with another in Java from the command prompt

I am doing an assignment for class and I was given a jar file for the Display board and I have to code some basic functions for it in a separate Java file. Now, I need the Display to be called in the program I'm writing, and so I used:

(I'm using a window PC)

javac -cp lab1.jar;.Wrapping.java

However, every time I try this, it gives me this error:

javac: no source files
usage: javac <options><source files>
use -help...

Now, I've changed my directory to the proper folder and the file is in there, and still, I cannot get it to run. What am I doing wrong? I can get other programs to compile and run from the command prompt, it is just this one that I cannot. Any help?

If your command it posted as you ran it literally, without the space between . and Wrapping.java, you need a space there.

Try this command to compile:

set classpath=lab1.jar
javac Wrapping.java

OR

javac -cp lab1.jar Wrapping.java

Try this command to execute:

set classpath=lab1.jar;.
java Wrapping ::Make sure its class name with main()

OR

java -cp lab1.jar;. Wrapping

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