The jar files are generated during build time and contain xml files that need to be read during run time. I am using Java webstart which downloads these jar file to a local folder. the local path to where the jar is stored is: C:\Users\username\Desktop\Project\jars
This folder contains multiple jar files. What i am trying to achieve is for the code to locate a particular jar based on a filename it contains and read an xml file contained in the jar. The xml file is located in a folder called xmlfiles in the jar but this is returning null.
Note: this used to work with previous versions of Java 3-5 but after our migration to Java 7, this method returns null. This is the portion of the method throwing the exception
private InputStream Jar(String _filename) throws IOException
{
String path = "xmlfiles/" + _filename;
InputStream content = Thread.currentThread().getContextClassLoader().getResourceAsStream(path)
System.out.println("loaded xml);
}
I have also tried getting the URL and printing out the string, but get a fileNotfound Exception
URL path = Thread.currentThread().getContextClassLoader().getResource(url);
I have tried various solutions with similar question on here but none of the solution can locate the file (returnin null or file not found) InputStream from jar-File returns always null Parse XML File within Jar Accessing a file inside a .jar file