在另一个目录中运行包含源文件的jar文件 [英] Running jar file with source files in another directory
问题描述
我想直接从命令行运行一个jar文件,而不必将jar文件放在包含我的输入文件的目录中。关于如果可能的话我怎么做的任何想法?
I would like to run a jar file right from the command line without having to put the jar file in the directory containing my input files. Any ideas on how I can do this if it is possible?
推荐答案
在执行时你不会只提供类路径参数吗? JAR里面的类?例如:
Wouldn't you just supply a class path argument when executing the class inside of the JAR? For example:
java -cp lib / somejar.jar org.foo.bar.MyClass
java -cp lib/somejar.jar org.foo.bar.MyClass
其中 - cp是classpath参数,lib / somejar.jar是你要执行的jar的路径。
Where -cp is the classpath argument and lib/somejar.jar is the path to the jar you are trying to execute.
我不确定我清楚你是什么正在寻找。
I'm not sure I'm clear on what you're looking for.
这篇关于在另一个目录中运行包含源文件的jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!