Hi Everyone ! I am a newby in java and experimenting with jars. I have an application reading an input txt file - when i created a jar for it, including the txt file, the jarred application can not seem to find the txt file. When i placed the txt file on the same directory as the jar file ok. What do i need to do so that the jarred application can see the input txt in the jar file ? Another question, can a txt file in a jar file be used as i/o or just input only ? Thanks !
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
If you put your text file inside the jar, you'll need the classes from the java.util.jar package to read them. It's not because your program runs the same, no matter whether your classes come from the class files or from a jar, that any file can be found inside the jar automatically! The classloader handles the difference between seperate class files and files in a jar, but for the text file you'll have to do it yourself ... Regards, G�nther http://www.javacoding.net
oliver flaviano
Greenhorn
Joined: Mar 10, 2002
Posts: 2
posted
0
Hi Gunther Thanks for your help ! After some hours of frustration , i finally found that jarfile is case sensitive and made my application worked.
Ramakrishnan G
Greenhorn
Joined: Mar 15, 2002
Posts: 3
posted
0
Hai Try this FileInputStream is = Class.forName("Your class Name ex: com.FileReader").getResourceAsStream("/"+ "filename.txt");