0

I'm using Maven Shade to make a shaded .jar file for a Jetty project. This project includes some resource files (text property files) that I'd like to read.

How do I access the files inside the said .jar file?

The current folder structure inside the jar when viewed from an file extraction tool is something like the following:
-com -some -domain -AccessFileFromHere.class -fileIWantToAccess.sql

I want to access the files in the combined jar files root named fileIWantToAccess.sql. I want to access this file from the java class AccessFileFromHere.class created from AccessFileFromHere.java.

The question asked here about accessing a jar file: Access file in jar file?
Can't be used as they are not using a shaded jar file.

Community
  • 1
  • 1
nipuna-g
  • 6,252
  • 3
  • 31
  • 48
  • A jar is a jar. For the classloader is doesn't make any difference how that jar is created, either with or without shading, by Maven, by Ant, etc... So the "Access file in jar file" contains the correct answer. – Robert Scholte Jul 18 '15 at 10:36
  • You are right. I tried following the previous question again and it worked. There was an error on my end. Sorry about the question. I'm new to SO, what should I do about the question? Should I delete it or could you please put your comment as an answer so I could mark it as the correct answer? – nipuna-g Jul 18 '15 at 14:55

1 Answers1

0

A jar is a jar. For the classloader is doesn't make any difference how that jar is created, either with or without shading, by Maven, by Ant, etc... So the "Access file in jar file" contains the correct answer.

Robert Scholte
  • 11,889
  • 2
  • 35
  • 44