I want to make a simple java program that creates a text file at somewhere. I want to let users choose the folder. But when I wrap it in jar file and send to others. Every time my friend runs it, it asks for the folder. I wonder how I can let the jar file only asks once and set it as final. Inside my .java file, I have something like
public void setDefaultFolder() {
//initially path is empty string
if(fc.getPath().equals("")){
String a = JOptionPane.showInputDialog("Please select a default folder." +
" Make sure it exists and it's not changeable once set");
if(a != null) {
String b = a.replace("\\","\\\\");
// set String path = something users enter
// fc is a helper object. I have all the read/write file or other methods
// there. I want to let the jar file read the path only for the first time
// and set the path final, later on, when it detects path is not empty
// string, it stops asking users to type in path.
fc.setPath(b);
}
else {
JOptionPane.showMessageDialog(null, "Folder not set");
}
}
}