我在生成报告后尝试打开 PDF 文件。我的意思是,用户登录(这是一个基于 Swing 的应用程序)并单击以生成报告。然后,生成一个 PDF 文件。我想在那一刻启动 PDF 阅读器。我可以做类似 exec("evince "+path_to_pdf_file)
的事情。只是对于Ubuntu来说,Windows会更困难。我想我需要探索一下注册表。
我怎样才能实现这个目标?
最佳答案
您需要的是方法java.awt.Desktop#open
Launches the associated application to open the file. If the specified file is a directory, the file manager of the current platform is launched to open it.
关于java - 如何确定从我的 Java 应用程序访问某些第三方程序和资源的方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4580743/