0

I use maven to create a runnable jar from multiple projects :

Project A (contains the Main class): /src/main/resources/META-INF/resources/a.txt

Project B (depends on Project A): /src/main/resources/META-INF/resources/b.txt

Runnable.jar (create with mvn): /src/main/resources/META-INF/resources/a.txt,/src/main/resources/META-INF/resources/b.txt

In the Main class I use Class.class.getResource to get the content of a.txt and b.txt. When I do java -jar Runnable.jar, I can access to a.txt and b.txt. But if I run it from Eclipse, I can only access to a.txt . Is it possible to get it right? I'd like to change resources content when the application is running and get the result without recompiling.

The Run configuration : [MAIN] => Project : Poject B, Main class : Main [ClassPath] => UserEntry : Project A, Project B

NB : If I change the order of the UserEntry, I can access to b.txt but not a.txt.

Could you help me?

fabian
  • 80,457
  • 12
  • 86
  • 114

2 Answers2

0

Project B needs to be added to Project A's Java Build Path. Open up project A's Properties dialog and do so.

nitind
  • 19,089
  • 4
  • 34
  • 43
  • On which tab? *getting sick and tired of this length requirement on comments* – nitind Sep 15 '14 at 22:38
  • I'm sorry i change the content of my question rather than use the comment to make the question more accurate. I don't know if this is the usage or I have to answer my own question to give more details. – user1382590 Sep 16 '14 at 07:18
0

I've found a solution. I've created a linked resource folder in project B (B/src/main/resources-a) which refers to the resources directory of project A (A/src/main/resources). I set the new linked folder as a source directory. Now it works and I can see the resources contained in the Project A in the target/classes folder of Project B. It's exactly what I expected but if I'd like 'mvn eclipse:eclipse' automaticaly configure .project and .classpath files?