I don't whether I am asking correct question or not but want to clear my doubt.
Actually I came across the scenario of referring class files from jar file. I mean to say I have one backend java project say ABC with application-context.xml file in it.
Now I created jar file of ABC project and used in one web based application.
Here I am facing a problem of beans not getting Autowired and came to know the problem was, When I export the jar file of ABC project using Eclipse, I have not selected "ADD DIRECTORY ENTRIES" checkbox which later on I did and all worked.
just to see what changes has been made by checking this box in a jar file so that all worked,
So I created 2 jar files one with "ADD DIRECTORY ENTRIES" checked and one with unchecked, then I compared both jar using beyond compare and found there is no difference at all.
Can someone explain me what exactly "ADD DIRECTORY ENTRIES" does?
what I know is it should add complete structure instead of single path like com/company/project/MyJavaFile.class
com/company/
com/company/project/
com/company/project/MyJavaFile.class
Please correct me if I am wrong.
You should enable "Add directory entries" when creating jar files if you need to use class.getResource() method to get the URI of a particular directory inside your jar file. The reason why you may want to do this is to hold a URI to your "resource" folder for example.
If you only use class.getResource() to get the URI of a specific file [and not a directory] then you will be fine if you leave the "Add directory entries" off.
Form Doc JAR File Exporter
Add directory entries: adds an entry for each directory to the JAR file, even if the directory does only contain subdirectories.
If you look at the jar file with 7-zip or something similar, you can see that there is a "D" attribute for the folders when "Add directory entries" is selected. These attributes do not exist when that that option does not exist. Your compare was probably comparing the contents of the files within the jar file and wasn't looking at the jar file attributes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With