6
I did a function that I can open a PDF, but this function is only working on my local machine. When I run . jar generated on another machine, an error is issued that the Pdfnão file exists.
The section that performs such a function:
try {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
desktop.open(new File("/manual.pdf"));
} catch (IOException ex) {
Logger.getLogger(JFrameInicio.class.getName()).log(Level.SEVERE, null, ex);
System.out.println(ex);
}
The PDF file is in the following location: \Documents Netbeansprojects Rectory src rectory
To create the JAR, I use the method package for store that in my mind, creates a jar with all the necessary files.
I think the PDF is being included in the final jar because without putting the PDF in the src folder, the jar is with a final size of 3 MB, my PDF also has 3MB. When I create the jar with the PDF file in the src folder, the final . jar is 6 MB in size (I believe it is the jar + PDF file)
Place the stack error please. It may be a directory issue.
– akira-ito
Java.lang.illegalArgumentException: The file manual.pdf doesn’t exist But if the error was in the directory, wouldn’t it not work even on my local machine? (both running by the IDE itself and by the jar
– Gustavo Rotondo
You have to create a temporary PDF file on disk, and read the file to this file. The ide runs its uncompressed problem, so it works, already running via
jar
, pdf is inside the package and does not exist external to it. See this here, it can help. http://stackoverflow.com/a/28808187/5524514– user28595
I will look thank you very much
– Gustavo Rotondo