The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Article: 
 (Not So) Stupid Questions 10: JAR Files
Subject:  Alternatives
Date:  2006-06-16 13:04:22
From:  kcoolsae
Response to: Alternatives


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.

 Feed java.net RSS Feeds