I am trying to read from a file that is packed inside a JAR, along with a class that reads it. For this, I use the following:
getClass().getClassLoader().getResourceAsStream(file)
This works fine when I create and run a JAR file on OSX, but if I create and run a JAR file on Windows, the above line returns null.
Am I missing something? If I create a JAR on OSX and run it on Windows, it works fine. The problem only occurs when creating a JAR on windows.
EDIT: It is worth noting that there is no folder hierarchy in the JAR file. Everything is stored at the same level, so the class that reads the file and the file itself are in the same directory. In addition, this is how I create the JAR file on both OSX and Windows:
jar -cmf manifest.mf run.jar *.class file1 file2
EDIT 2: The file I'm trying to download is a java.properties file. I suppose this is not what causes the problem?
source
share