I have a project in which I have several embedded files.
However, when I try to access these files in the code:
Statics.applicationProperties = loadPropertyFile("application.properties");
public Properties loadPropertyFile(final String filename) {
Properties props = new Properties();
try {
props.load(new FileReader(filename)); //<-- file not found exception here
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return props;
}
I get the following error:
[08:44:06] [Server thread/WARN]: java.io.FileNotFoundException: application.properties (The system cannot find the file specified)
[08:44:06] [Server thread/WARN]: at java.base/java.io.FileInputStream.open0(Native Method)
[08:44:06] [Server thread/WARN]: at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
[08:44:06] [Server thread/WARN]: at java.base/java.io.FileInputStream.<init>(FileInputStream.java:155)
[08:44:06] [Server thread/WARN]: at java.base/java.io.FileInputStream.<init>(FileInputStream.java:110)
[08:44:06] [Server thread/WARN]: at java.base/java.io.FileReader.<init>(FileReader.java:60)
[08:44:06] [Server thread/WARN]: at net.mcnations.nationsatwar.utils.InitializrUtils.loadPropertyFile(InitializrUtils.java:168)
I am packaging this jar file via Maven's build goals compile package
.
Are these resources just not being included? I don't get it, as they are very clearly within the resources section of the project.