java.awt.Desktop不起作用

时间:2012-08-10 14:06:53

标签: java file awt desktop

我的电脑的系统是XP,当我打开doc,txt或ppt这样的文件时,这段代码不起作用。我已经有office2007,但是如果没有erro Info,desktop.open(文件)就无法打开任何文件。有些电脑可以正常工作,为什么?

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;  
      }  
     } 

1 个答案:

答案 0 :(得分:0)

你可以在堆栈溢出中检查这个链接,讨论同样的事情。但请发布错误,以便我们更好地理解。

Facing problems with java.awt.Desktop in 64 bit JVM?

相关问题