【发布时间】:2016-07-20 14:23:19
【问题描述】:
我正在用 java 做一个小的大项目。使用的版本是 JRE6 with eclipse Indigo。
应用程序似乎工作正常,但是当我想执行这个 api 的可运行 jar 时,它不起作用。 所以我用 c:...\jr6\bin\java.exe -jar c:\User\Olivier\Desktop\appli.jar 执行我的 jar
然后第一个问题是关于两个罐子我必须倒置以使它们工作。 (2 个 xstream 罐子)
现在,出现了一个新错误。应用程序似乎无法加载文件名 language.properties
我将它与其他 jars 一起添加到 appli.jar 的文件夹中,我也尝试将它添加到清单中。我自己显然无法解决这个问题。
如果有人有想法?
protected Properties readPropertiesFile(final String filename,final int level){
if (filename == null) {
return null;
}
//if first level (0) then clear the list of already loaded files
if (level == 0) {
this.alreadyLoadedFiles.clear();
}
InputStreamReader stream = null;
try {
//Try to open a connection with the properties file
stream = new InputStreamReader(new FileInputStream(filename), "UTF-8");
} catch (FileNotFoundException e) {
//Try to find the specified propertie file in Classpath
this.logServices.severe("Cannot found the '"+filename+"' properties file.");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
this.logServices.severe("UnsupportedEncodingException '"+filename+"' properties file encoding in UTF-8");
}
//Read the properties file
Properties props = new Properties();
try {
props.load(stream);
//Add the file in the list of already loaded file
this.alreadyLoadedFiles.add(filename);
} catch (Exception e) {
props = null;
this.logServices.severe("Cannot read the '"+
filename+"' properties file : "+e.getMessage());
} finally {
try {
stream.close();
} catch (IOException e) {
}
}
//Search for the include Tag in properties file
this.readIncludePropertiesFiles(props, (level+1));
return props;
【问题讨论】:
-
我展示了用户的属性系统,我试图把我所有的属性都放在里面,它就像这样工作。不幸的是,我希望将属性与 jar 链接而不是与系统链接,就像我采用我的解决方案一样,我不知道用户目录是什么。那么,是否有办法改变这一事实?
标签: java properties java-6 eclipse-indigo