在命令行上向类路径添加多个 jar [英] Adding multiple jars to classpath on commandline
本文介绍了在命令行上向类路径添加多个 jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在运行 Ubuntu 并希望通过包含多个 jar 文件从终端执行 Java 文件.
I'm running Ubuntu and want to execute a Java file from terminal by including multiple jar files.
我所有的 jars 都包含在 tha 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 开始,您可以使用类路径通配符
Since Java 6 you can use classpath wilcards
javac -cp jar/*:. MyFile.java
这篇关于在命令行上向类路径添加多个 jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文