0

我的电脑系统是XP,当我打开doc、txt或ppt之类的文件时,这段代码不起作用。我已经有office2007,但是没有错误信息,desktop.open(file)无法打开任何文件。有些电脑可以正常工作,为什么?

public boolean byDesktop(String path){  
      File file = new File(path);  
      if(file.isFile()){   
       Desktop desktop = Desktop.getDesktop();  
       try {  
        desktop.open(file);  
                } catch (IOException e) {  
                 System.out.println(e);  
                }  
       return true;  
      }else{  
       return false;  
      }  
     } 
4

1 回答 1

0

您可以在讨论相同内容的堆栈溢出中检查此链接。但请务必发布错误,以便我们更好地理解。

在 64 位 JVM 中遇到 java.awt.Desktop 问题?

于 2012-08-10T14:29:34.027 回答