【问题标题】:Reading properties file outside jar读取jar外的属性文件
【发布时间】:2015-07-13 15:10:18
【问题描述】:

我的 jar 文件和属性文件位于同一位置 (C:\test)。当我通过脚本运行 jar 时,它会为属性文件引发 FileNotFound 异常。这通过 RAD 完美运行。我在这里做错了什么。我尝试了其他方法,例如获取 jar 文件的路径等,但也没有运气。

脚本:

@echo off
REM Eventually change directory to the program directory 
cd C:\test\
REM run the program
"C:\Program Files (x86)\Java\jre6\bin\java.exe" -jar  "C:\test\test.jar"

读取属性文件的代码:

    private void loadProperties() throws IOException{

    appProperties = new Properties();
    InputStream in = new FileInputStream("./EDMSWS.properties");
    appProperties.load(in);
    in.close();
}

清单文件:

Manifest-Version: 1.0
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
Rsrc-Class-Path: ./ commons-io-2.4.jar JSQLConnect.jar poi-3.11-201412
21.jar
Class-Path: .
Rsrc-Main-Class: com.example.xxx.xxxxx

【问题讨论】:

    标签: java jar runnable


    【解决方案1】:

    你可以尝试使用 InputStream in = new FileInputStream("./EDMSWS");

    【讨论】:

    猜你喜欢
    • 2012-02-05
    • 2016-11-29
    • 2019-04-23
    • 2017-11-14
    • 1970-01-01
    • 2017-06-04
    • 1970-01-01
    • 1970-01-01
    • 2016-08-04
    相关资源
    最近更新 更多