【问题标题】:Java Eclipse(RFT) : Cannot read ressource in jarJava Eclipse(RFT):无法读取 jar 中的资源
【发布时间】:2018-10-18 17:39:24
【问题描述】:

在我尝试用它创建一个 jar 之前,我的项目运行良好... 从这个类/TS_Generic_Engine/auto_engine_class/Resources.java 我正在解析这个 xml 文件:/TS_Generic_Engine/resources/values/strings.xml

String stringFilename = "resources/values" + langId + "/strings.xml"; 
InputStream fXmlFileStream = getClass().getResourceAsStream("../" + stringFilename);

    if ( fXmlFileStream == null ) {
        if (language == RESOURCE_LANGUAGE.LANG_DEFAULT) {
            System.out.println("WARNING: No default strings resource found. Expected: " + stringFilename);
        }
        return null;
    }

工作正常,但是当我将项目导出到 jar 中时,我的大多数 java 文件都会出现“导出时出现编译警告”..

当我尝试运行这个 jar 时,有这样的输出:

WARNING: No default strings resource found. Expected: resources/values/strings.xml
WARNING: Resources have not been initialized.
WARNING: Resources have not been initialized.
WARNING: Resources have not been initialized.
Exception occurred during playback of script [UserControlScript] [CRFCN0019E: RationalTestScriptException on line 56 of script UserControlScript - java.lang.NullPointerException: null.].

如果我解压缩 jar,文件的位置是 MyJar.zip/resources/values/string.xml 和 MyJar.zip/auto_engine_class/Resources.java。

【问题讨论】:

    标签: java jar resources


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 2012-04-07
      • 2015-02-16
      • 2014-06-07
      • 2018-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      相关资源
      最近更新 更多