eclipse - Where does Java put resource files when I JAR my program? -


Looking for this for the last two hours and can not find anything (I found a solution to the same problem But with images, not text files).

Too much, I created a program that reads the text file, is a list of file names and ids using Eclipse, I've put the file in my src folder and put the path file in the program is. Like this:

  In = new buffer reader (new file reader (curDir + "\\ bin \\ items.txt"));   

where curdir is the current directory of the user (with System.getProperty ("user.dir").

Now, the problem is, when I run it from eclipse, but when I try to make it a runner jar and then run it, the program continues, but information from the text file It does not seem that the load does not appear that the eclipse is not putting a text file with a jar.

Edit: Is the problem solved? So the jar file needs to be in the folder with all the original files? I am very confused, what is a jar file?

Another strong way to get a file is by running Eclipse or JAR

  MyClass.getResource ("items.txt")   

Where MyClass is a resource in the same package (folder) that you the wanted.

If Eclipse is not putting files in your JAR, then you can run

- gt; Run configuration - & gt; - & gt; Cells tab - & gt; Advanced - & gt; Add folder

Then add the folder to which your file is included in the classpath. Alternatively, export the ant script and create custom build scripts.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -