In debugging I found that my current way of storing a database's files (embedded derby database
) didn't work when running the executable .jar
file that's compiled by NetBeans 8.0
.
Simply put, I need a way of getting the application to find the directory the .jar
file is being run from, and to set up the embedded DB database
in the same directory.
In case it helps, the current way I get it to 'work' (within the IDE) is as follows:
public final void setDBSystemDir() throws UnsupportedEncodingException, SQLException{
String path = DataBase.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String decodedPath = URLDecoder.decode(path, "UTF-8");
String systemDir = decodedPath + "/listData/";
System.setProperty("derby.system.home", systemDir);
}
Any pointers welcome.