本文介绍了在命令行上将多个jar添加到类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在运行Ubuntu,想通过包括多个jar文件从终端执行一个Java文件。
I'm running Ubuntu and want to execute a Java file from terminal by including multiple jar files.
所有我的jar包含在jar文件夹中。
All my jars are included in tha jar folder.
我试过
javac -cp jar/A.jar: jar/B.jar: jar/C.jar: jar/D.jar MyFile.java
我得到以下错误。
javac: invalid flag: jar/B.jar:
Usage: javac <options> <source files>
use -help for a list of possible option
任何人都可以指导如何使用多个jar在类路径中?
Can anyone guide how to use multiple jars in classpath ?
推荐答案
从类路径中删除空格并添加当前路径
Remove the spaces from the classpath and add the current path
javac -cp jar/A.jar:jar/B.jar:jar/C.jar:jar/D.jar:. MyFile.java
从Java 6开始,你可以使用classpath wilcards
Since Java 6 you can use classpath wilcards
javac -cp jar/*:. MyFile.java
这篇关于在命令行上将多个jar添加到类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!