You can access any file (whether Java-class, properties-file, xml-file or data file - you name it) from a jar which is in your class path using getClass().getResourceAsStream (...). This returns an InputStream which you can read as if it were a normal file.
Using this technique has the added advantage that your program keeps working when deployed in a different way (as an expanded jar, as jars on a web server, ...). The program doesn't need to know whether the files really belong to a jar. |