Creating Runnable Jar with external files included
Here's what you should do instead:
Put that file back in your jar file. Use class.getResourceAsStream()
to read it instead of File
and FileReader
. Here is an explanation of how to do that: How to really read text file from classpath in Java
Problem Solved!
here is how:
1) right click your project folder and create a new folder.
2) move all of your files that you want packed into the jar into that folder.
3) click project -> properties -> Build Path -> Source -> Add Folder
and select that folder you just created.
4) create your JAR!
Since you already have created your folder with abc.txt insideit, you can skip steps 1 and 2
EDIT: one way you can make sure your JAR contains these files is to use 7zip.