1

I have been trying to launch browser from a java app on Linux. When this app is run for the first time browser don't get opened. The error log shows : shell-init: cannot get current directory getcwd : no such file or directory.

After this if u restart everything falls into place and browser opens fine.

I have tried many things like changing current directory to /tmp using SYstem.setPropert() , but nothing works.

There are many question on this site like this but they didn't help. Will appreciate if someone can provide a workaround.

4

2 回答 2

0

如果没有获得任何详细信息,您的 Java 代码很可能没有足够的权限访问该目录。

于 2009-08-27T14:21:35.830 回答
0

这是我为这个问题找到的最佳方法,因为无论浏览器安装在哪里或其他任何地方都无关紧要,java 与操作系统通信并发出运行默认浏览器的请求。

String url = "https://yourdomain.org/";
java.awt.Desktop.getDesktop().browse( java.net.URI.create(url));
于 2021-01-26T17:25:21.707 回答