I want to access a file inside a jar and unmarshall it. But I cannot access it with the path as we do with the files. What is the best way to do it?
Asked
Active
Viewed 402 times
2 Answers
0
I assume that the file you want to access is inside the resources folder. When you generate a jar the path changes, maybe this post would help you: Access file in jar file?

Erick Valencia
- 36
- 5
-
it is a maven dependency jar. It is located in the local maven repo. I have the path. I want to access the property file inside that jar. I want to do this for all projects in the workspace.Like Iterating through the dependencies and read properties for each. So i think that won't work. – kiri Nov 09 '20 at 03:33
-
@kiri : have you tried it? It _does work_ – Jayan Nov 09 '20 at 03:40
-
In my case, i am accessing the project from outside. I am not inside the project. I am doing eclipse plugin development and i am iterating through each project as IProject and get their ClassPathEntries. From that i can get the location of it. (my interested one is in the maven repo ). I tried to do as follows but didn't work. `for (IClasspathEntry classpathEntry: classPathEntries) { InputStream is = classpathEntry.getClass().getClassLoader().getResourceAsStream("META-INF/Packages.xml");}` – kiri Nov 09 '20 at 03:47
-
This post has something similar https://stackoverflow.com/questions/16570523/getresourceasstream-returns-null – Erick Valencia Nov 09 '20 at 04:27