0

I know that this question it is similar to this one but it is different. I am trying to open a pdf file that it is in the resources folder of netbeans.

This is my project structure

Right now I am in the EventoService.java and I have created a file object to open the pdf file (justificante.pdf) in "Other Resources" folder. I have tried to reach the pdf file like in the link before but it doesn't work because of the constructor. How can I reach it? Thank you in advance.

if (Desktop.isDesktopSupported()) {
                try {
                    File myFile = new File(getClass().getClassLoader().getResource("resources/justificante.pdf"));
                    Desktop.getDesktop().open(myFile);
                } catch (IOException ex) {
                    // no application registered for PDFs
                }
            }
largoWinch
  • 377
  • 1
  • 4
  • 20
  • 1
    https://stackoverflow.com/questions/15749192/how-do-i-load-a-file-from-resource-folder – PeterMmm May 27 '17 at 15:25
  • @PeterMmm ok, I can read it, but do you know how can I open it in the browser? – largoWinch May 27 '17 at 15:35
  • As stated in the docs `open()` will open the associated application. If your machine does not open anything, then it is a problem of the association in the OS, not Java. https://pdf.iskysoft.com/pdf-tips/open-pdf-in-browser.html – PeterMmm May 28 '17 at 07:09

0 Answers0