Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想直接从命令行运行一个 jar 文件,而不必将 jar 文件放在包含我的输入文件的目录中。如果可能的话,关于我如何做到这一点的任何想法?
在 JAR 中执行类时,您不会只提供类路径参数吗?例如:
java -cp lib/somejar.jar org.foo.bar.MyClass
其中 -cp 是类路径参数,而 lib/somejar.jar 是您尝试执行的 jar 的路径。
我不确定我是否清楚你在寻找什么。