I am trying to build a very little program with MAVEN that reads from a file but I obviosly do something wrong because it gives me FileNotFoundException.
This is how my directory structure looks like:
my-app
src
main|
|
|--java|
| |
| Main.java
|
|--resources|
|
res.txt
The res.txt contains some Strings that I'd like to read from Main.java
...
File file = new File("res.txt");
FileReader fr= new FileReader(file);
BufferedReader br = new BufferedReader( fr);
...
I compile it with : C:\my-app mvn package
It creates the jar under target. When I peep inside the jar, I see it contains both Main.class and res.text next to each other.(under the same directory)
Still, when I try to run it :
java -cp target/my-app-1.0-SNAPSHOT.jar Main
I gives my FileNotFoundException, Main.class somehow does not see res.txt file. Why? Where should I put res.txt? What else should I configure?
Any help would be greatly appriciated.