I have two independent projects A and B both are being built using maven. Project B is more of a resources project. I am using maven to package jar for this project.
Now for project A, i add project B’s jar as the dependency. How i will be able to access resource files from project B’s jar in side some java file in project A.
I have confirmed that jar for Project B is being installed in Maven’s local repository.
I searched alot but none of the answers seem to help.
Following is the directory structure for
src
|_
main
|_
resources
|_
dir1
|_
dir2
|_
dir3
|_
Some_config_file.txt
I want to access this Some_config_file.txt from Project A, how can i find the path relative to classpath
Any help / suggestions ?
Yes, all files from
src/main/resourcesare part of the final JAR and they are in the same path as classes. In other words your_Some_config_file.txtwill land up next to_dir1._dir2._dir3.Foo.classcompiled class.All such items are placed on flat CLASSPATH, i.e. contents of each JAR share the same namespace on the CLASSPATH. In order to read such file, you need to using
ClassLoader: