Is there any way to have a code that opens a PDF file in Java application in a platform independant way? I mean using a batch file in Windows could do that. Is there any oth
Use this to open pdf file using java
File file = new File(filepath);
if (file.toString().endsWith(".pdf"))
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file);
else {
Desktop desktop = Desktop.getDesktop();
desktop.open(file);
}
This code is used to open your pdf and other files.