Here's a way to do it (if I understand you correctly). Just let explorer.exe do it for you.
import java.awt.*;
public class openPDF
{
Desktop desktop = Desktop.getDesktop();
public openPDF()
{
open("test.pdf");
}
public void open(String path)
{
try
{
Runtime.getRuntime().exec("explorer.exe "+path);
} catch(Exception e) { System.out.println("NAI! ERROR!\n"+e); }
}
public static void main(String[] args)
{
openPDF myApplication = new openPDF();
}
}
you may find something here
http://schmidt.devlib.org/java/libraries-pdf.html
or check this old thread
http://forum.java.sun.com/thread.jspa?threadID=288610&messageID=1785204
or this link
http://www.google.com/search?hl=en&q=display+pdf+with+swing&btnG=Search
> Here's a way to do it (if I understand you
> correctly). Just let explorer.exe do it for you.
>
> > import java.awt.*;
>
> public class openPDF
> {
> Desktop desktop = Desktop.getDesktop();
>
> public openPDF()
> {
> open("test.pdf");
> }
>
> public void open(String path)
> {
> try
> {
> Runtime.getRuntime().exec("explorer.exe "+path);
> } catch(Exception e) { System.out.println("NAI!
> I! ERROR!\n"+e); }
> }
>
> public static void main(String[] args)
> {
> openPDF myApplication = new openPDF();
> }
>
> }
>
Why do you have a Desktop object as a member but instead of using it, you execute a command with Runtime (which is not platform independent!)?
-Puce