You can pack your application in a .jar, actually a zip file with inside .class files and resource files. Those resource files, like your images, can be taken with getClass().getResource("path/x.png")
or getResourceAsStream
. The path is either package relative or absolute: "/abc/def.jpg".
These resources must be read-only (as they are inside the .jar). However you may store an Excel template as resource, and copy that to the user's directory.
System.getProperty("user.home")
Will give the user's directory where you may copy your resource to.
Path appWorkspace = Paths.get(System.getProperty("user.home"), "myapp");
Files.createDirectories(appWorkspace);
Path xlsx = appWorkspace.resolve("untitled.xlsx");
Files.copy(getClass().getResourceAsStream("/data/empty.xlsx"),
xlsx);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…