【发布时间】:2015-09-11 22:08:29
【问题描述】:
我开发了一个小型 java 应用程序并将其导出到 jar 文件(形式 eclipse)。在这个应用程序中,我使用 xml 文件名从以下位置读取输入数据:
private static final String INPUT_FILE_NAME = "./tasks.xml";
............
//read input tasks queue
XMLDecoder decoder = null;
try {
decoder = new XMLDecoder(new BufferedInputStream(
new FileInputStream(INPUT_FILE_NAME)));
searchTasksQueue = (BlockingQueue<SearchTask>) decoder.readObject();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (decoder != null) {
decoder.close();
}
}
当我运行 jar 文件时,我将任务文件放在与 jar 相同的文件夹中。 在 windows 7 下一切正常。虽然当我在 windows 2008 服务器下做同样的事情时,我得到:
C:\Users\Administrator>java -jar c:\scraper\scraper.jar
java.io.FileNotFoundException: .\tasks.xml (The system cannot find the file spec
ified)
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 bmw.scraper.Starter.main(Starter.java:40)
哪里出错了?在 Windows 2008 服务器下运行它需要检查什么?
PS
- 在我的 Win 7 java 版本“1.8.0_45”上
- 在 win 2008 服务器 java 版本“1.8.0_60”(通过 RDP 客户端运行)
【问题讨论】: