【问题标题】:Execute Java Jar from Windows Command with External Properties file on C drive使用 C 驱动器上的外部属性文件从 Windows 命令执行 Java Jar
【发布时间】:2016-11-30 10:04:04
【问题描述】:

我想知道如何在 Windows 命令行中包含指向我的属性文件的路径,以便执行我的 JAR 文件。

Jar/命令行:java -jar Parser.jar 属性文件:C:\Properties\Parser.properties

我试过了,来自另一篇文章:

java -jar Parser.jar -Dconfig=C:\Properties\Parser.properties

但这会导致:

Exception during initialize() java.io.FileNotFoundException: Parser.propertie
s (The system cannot find the file specified)
java.io.FileNotFoundException: Parser.properties (The system cannot find the
file specified)
        at java.io.FileInputStream.open0(Native Method)
        at java.io.FileInputStream.open(Unknown Source)
        at java.io.FileInputStream.<init>(Unknown Source)
        at java.io.FileInputStream.<init>(Unknown Source)
        at xxx.xxx.xxx.system.tools.parser.ParserMain.initialize(Parser
Main.java:100)
        at xxx.xxx.xxx.system.tools.parser.ParserMain.main(ParserMain.j
ava:55)

【问题讨论】:

  • 如果属性文件是从类路径中选取的,只需添加到类路径中就可以了。 java -classpath "C:\Properties\Parser.properties" -jar Parser.jar

标签: java jar properties command


【解决方案1】:

我最终想通了。我将属性文件移动到与 jar 文件相同的目录并且它工作。即 Jar 在 C:\Parser\ 中,所以我将属性文件移动到 C:\Parser\ 就是这样...... :)

【讨论】:

    猜你喜欢
    • 2012-04-25
    • 2012-07-09
    • 1970-01-01
    • 2020-04-17
    • 1970-01-01
    • 1970-01-01
    • 2012-11-19
    • 1970-01-01
    • 2012-01-01
    相关资源
    最近更新 更多