0

[![enter image description here][1]][1]I am trying to load folder. This folder is placed inside JAR when the Project is build and this JAR file is located inside ZIP.

When I try to load as the resource, this is the value its returning.

ClassLoader classloader = Thread.currentThread().getContextClassLoader();
URL resource = classloader.getResource("templates");

zip:-

zip:/u01/app/iotdomain/servers/d1/tmp/_WL_user/mnt/artifacts/iot/server/
ServerCon/p7u/lib/Verticals.jar!/templates

Tried many different ways but couldn't find the solution.

Karthik GVD
  • 91
  • 1
  • 2
  • 9
  • Let me clarify your situation: You need to load a resource that is located inside your _jar file_ and this jar file is packed in a _zip archive_? – xoX Zeus Xox Aug 03 '17 at 05:59
  • Yes, When I tried URI uri = this.getClass().getClassLoader().getResource(foldername).toURI(); I checked for URI scheme, its returning me the "zip". And by looking at the path above templates folder is inside the JAR. Together its inside JAR folder placed inside ZIP. – Karthik GVD Aug 03 '17 at 06:00
  • So if I understand correctly you don't want to get a resource from within your _currently running_ jar, but rather a different jar file that is located within a zip archive somewhere else? – xoX Zeus Xox Aug 03 '17 at 06:06

1 Answers1

0

As you stated in your question, the resource that you need to get access to is located

inside JAR when the project is build

and the jar file is packed inside a zip archive:

this JAR file is located inside ZIP

That would mean that this image is a representation of your project structure with your resource in its resource folder

Your project as seen in eclipse, with your resource in its resource folder

and this whole project is exported as a jar file and said jar file is then again packed in a zip.

If that is the case, you can access your file as stated here.

If I did not get your point please provide a picture of your project hierarchy or clarify where all the relevant files are located.

xoX Zeus Xox
  • 195
  • 1
  • 14
  • Here is my project structure. I am not aware of all the file names inside folder. I have to read all the contents of file. https://i.stack.imgur.com/30Zgo.jpg – Karthik GVD Aug 03 '17 at 06:40
  • After looking at the solution link that you gave me, it looks to me that I misunderstood. Lookslike the templates folder is zipped inside verticals JAR – Karthik GVD Aug 03 '17 at 07:20