JAR 清单中的默认参数 [英] Default arguments in JAR-manifest
问题描述
有没有办法创建一个 JAR 文件,其中包含一些传递给主类的参数?(无论是在潜在的命令行参数中添加参数还是附加参数都无关紧要.)
Is there a way to create a JAR-file that contains some arguments that are passed to the main class? (It does not matter whether it prepends or appends the arguments to potential command line arguments.)
我知道我可以简单地编写一个引导类并将其指定为主类(使用参数调用真正的主类),但这似乎有点尴尬.
I know I could simply write a bootstrapping class and specify this as main class (calling the real main class with the arguments), but this seems a bit awkward.
推荐答案
据我所知,没有.你必须自己在代码中做那种事情.
To the best of my knowledge, no. You'll have to do that kind of thing yourself, in code.
很多人发现编写一个小的主类来设置环境然后充当真实"主程序的类加载器很有用.通常,此类 pre-mains 会摆弄其应用程序的类路径,但您遇到的问题是可以像这样解决的其他问题.
A lot of people find it useful to write a little main class that sets up an environment and then acts as a ClassLoader for the "real" main program. Typically, such pre-mains fiddle with the classpath of their application, but your kind of problem is something else that could be solved like this.
这篇关于JAR 清单中的默认参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!