We have a java swing application which contains documents module when double-clicking any of the document which is opening in my IDE(Eclipse). Every time when I am executing my code which is working fine in the codebase but Unable to view a document in Java 11 dmg and it is working fine in Java 8, dmg as well in codebase also working good in the EXE. This is the error I am getting every time while trying to open a document during runtime java.io.IOException: Cannot run program "open": error=2, No such file or directory This is my code,
ProcessBuilder ps = new ProcessBuilder("open", documentLocation);
ps.start();
Have tried,
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("bash", "-c", "sudo chmod 755"+ " "+documentLocation+"");
ProcessBuilder ps = new ProcessBuilder("open","-n", documentLocation);
ps.start();
another attempt,
File file = new File(documentLocation);
Runtime.getRuntime().exec(new String[]{"/usr/bin/open", file.getAbsolutePath()});
This is working file in codebase in MAC, How do I fix this on dmg(Runtime execution) What changes need to be done in my code.