importing external jar files

后端 未结 1 1759
忘掉有多难
忘掉有多难 2020-12-28 23:15

I have written a Java code which imports an external jar file. How can I compile and run it on the command-line?

Thanks in advance!

1条回答
  •  南笙
    南笙 (楼主)
    2020-12-28 23:43

    Compiling from the command-line:

    javac -cp path_to_jar1.jar:path_to_jar2.jar Example.java
    

    Running:

    java -cp .:path_to_jar1.jar:path_to_jar2.jar Example
    

    For Windows, use ; as a path-separator (instead of :).

    0 讨论(0)
提交回复
热议问题