I have been reading the same questioned that were asked here and on Quora, however, I still don`t understand why I cannot access the file that is located in the 'src/main/resources' folder. Everything works when I specify relative path manually "src/main/resources/config/serverConf.xml"
Project structure:
src/main/java/"project related folders"
src/main/resources/config/serverConf.xml
And the main class:
public class Main{
public Main(){
File file = new File(this.getClass().getResource("config/serverConf.xml").getPath());
if(file.exists())
System.out.println("Yes");
else
System.out.println("No");
}
public static void main(String[] args){
Main main = new Main();
}
}