我有一個使用屬性文件的eclipse項目。該文件位於項目的根目錄中。我希望能夠運行使用cmd在eclipse中生成的.class文件(在Windows中)。運行jar文件/ .class文件以及屬性文件
我用這個代碼從文件中獲取屬性:
Properties prop = new Properties();
FileInputStream fileStream = new FileInputStream("DBConfig.properties");
prop.load(fileStream);
但是當我運行的.class文件我得到這個錯誤:
couldn't read property file...
我怎樣才能做到這一點?
我也看到類似這樣的帖子,但他需要覆蓋系統屬性,我不這樣做:Execute a jar with an external properties file。
將屬性文件在您的.class文件駐留 – Keerthivasan
試過沒有幫助 –