简体   繁体   English

java.awt.Desktop不起作用

[英]java.awt.Desktop doesn't work

My computer's system is XP and when I open files like doc, txt or ppt,this code doesn't works.I already have office2007 , but desktop.open(file) can't open any file without erro Info. 我的计算机系统是XP,当我打开doc,txt或ppt之类的文件时,此代码不起作用。我已经有了office2007,但是desktop.open(file)在没有erro Info的情况下无法打开任何文件。 And some computers can work fine , why? 而且有些计算机可以正常工作,为什么?

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

You could check this link in stack overflow which discusses the same thing. 您可以在讨论相同问题的堆栈溢出中检查此链接。 But please do post the error so that we'll get a better understanding. 但是请发布错误,以便我们更好地理解。

Facing problems with java.awt.Desktop in 64 bit JVM? 在64位JVM中面对java.awt.Desktop的问题?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM