[Solved] Producing a Java program for other systems


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);

4

solved Producing a Java program for other systems