I tried to export a Java program from Eclipse to a .jar file, but I came across a problem. It ran fine, but for some reason it didn't find the text files it was supposed to get data from. If anyone could help with this, I would be very grateful.
+3
A:
Where are these text files ? If they're packaged within your .jar file, I would expect to be able to find them within the class hierarchy using ClassLoader.getResourceAsStream(), specifying the complete path relative to the classloader base.
Brian Agnew
2009-12-26 21:26:54
A:
If your program depends on internal text files, put them in classpath and package them in the jar. Find them with the Class.getResourceAsStream.
bmargulies
2009-12-26 21:27:21
A:
I guess we need some more information to help you solve this problem. Where are your text files located while debugging and developing your code? Make sure that they are accessible from the path you are running the jar in.
moritz
2009-12-26 21:27:34
all of the files, text and source alike, are in the same package.
Renee
2009-12-26 21:34:43