【发布时间】: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