【发布时间】:2013-12-23 12:28:21
【问题描述】:
我创建了一个可执行的 jar 包(称为 myjar.jar),它有一个用于读取配置文件的类(称为 config_reader)。myjar.jar 之外还有另一个使用 config_reader 的类文件。但是 config_reader 的配置文件放在 myjar.jar 之外(在本地文件系统中)。现在,当我尝试执行可执行 jar 以及另一个使用它的文件时,我收到一条错误消息,提示找不到配置文件:
我试过了 :
java -classpath config myclass.class
有人可以帮忙吗?
config_reader的代码是:
public class config_reader()
{
public static ArrayList<String> get_prop()
{
Properties prop = new Properties();
ArrayList<String> s= new ArrayList<String>();
try {
//load a properties file
prop.load(new FileInputStream("config"));
//get the property value and print it out
s.add(prop.getProperty("source_folder_dir"));
s.add(prop.getProperty("dest_folder_dir"));
s.add(prop.getProperty("file_type"));
s.add(prop.getProperty("username"));
s.add(prop.getProperty("userpwd"));
s.add(prop.getProperty("exclusion_list"));
} catch (IOException ex) {
ex.printStackTrace();
}
return s;
}
}
【问题讨论】:
标签: java ubuntu terminal classpath config