How to open a pdf file in java

Today i’m going show how to open a pdf file using java code.


import java.io.IOException;

public class PDFopen {
       public static void main(String[] args) {
              try {
                   String cmds[] = new String[]{"cmd", "/c","Your File Path\\PDF_NAME.pdf"};
                   Runtime.getRuntime().exec(cmds);
              } catch (Exception e) {
                   System.out.println(e);
              }

       }
}

One thought on “How to open a pdf file in java

Leave a comment