java - Export runnable jar with eclipse -
i have program java swing program reads .txt file. when try make runnable jar file cant read it. how can make runnable jar such program? thanks
file -> export -> java -> runnable jar file
make sure setting launch configuration .jar file correctly, , extracting required libraries .jar well.
the text file not being pointed right location in source code. suggest looking jfilechooser , getting location of selected file that. have text file pinpointed 1 directory. example of this:
file dir = new file(system.getenv("appdata"), "folder"); if (dir.exists() && dir.isdirectory()) file file = new file(dir, "input.txt"); this code sets folder in user's appdata folder on computer (windows). file created afterwards put folder. using code that, can read file no matter .jar file placed, long input.txt exists @ location.
Comments
Post a Comment