Recently I have an issue with Java. I've tried some things I found on the web but they haven't worked, so I need help.
I have a Java project in Eclipse. My main class is in src/programCode/UI_Main2.java. In that .java I try to access to a file in src/files/File.file
And this is when the things fo weird.
If I use
/src/files/File.fileit gives meNoSuchFileException.If I use
src/files/File.fileit works in Eclipse but when I compile it to a executable .jar it gives meNoSuchFileException.If I use
/files/File.fileit gives meNoSuchFileException.If I use
files/File.fileit gives meNoSuchFileException.If I use
files/File.fileit gives meNoSuchFileException.If I use
this.getClass().getResource("/files/File.file").getPath().substring(1)(without substring it gives me Invalid character) it gives meNoSuchFileException(but it shows me the absolute path and the file exists there!)If I use
this.getClass().getResource("files/File.file").getPath()it gives meNullPointerExceptionand the program crashes.If I use
this.getClass().getResource("src/files/File.file").getPath()it gives meNullPointerExceptionand the program crashes.If I use
this.getClass().getResource("/src/files/File.file").getPath()it gives meNullPointerExceptionand the program crashes.
So, I don't know what to do. src/files/File.file is the only one that works, but it doesn't when compiled to executable jar. So please, help me, I haven't found any solution yet.
Thanks!