我已经在eclipse中通过选择的Runnable Jar文件通过eclipse创建了我的项目的jar文件。当我在我的cmd中运行这个jar文件时它工作正常,但是当我把它放在其他系统/ pc上时它不能正常工作,即它找不到.properties文件。因此,那些需要.properties的操作不是通过cmd执行的,其余的操作都运行良好。在这种情况下我需要做什么?
参考代码:
try {
// Loads the constants.properties file
InputStream constantPropFile = ClassLoader.class.getResourceAsStream("/constants.properties");
constantProp.load(constantPropFile);
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}