2应用在同一个JRE,从java.awt.Desktop.isDesktopSupported得到不同的结果() [英] 2 apps in the same JRE, are getting different result from java.awt.Desktop.isDesktopSupported()
问题描述
我有一个使用的java.awt.Desktop
一个Maven项目。我使用它的谷歌认证,所以我需要一些方法来打开登录谷歌浏览器对话框,然后用户确认。
I have a Maven Project that uses java.awt.Desktop
. I'm using it for Google Authentication, so I need some way to open a browser dialog for Google Login, and user confirmation.
我出口该库在一个.jar文件,我打算把它列入大量的Liferay的Portlet,在WEB-INF / lib目录
I'm exporting that library in a .jar file, that I intend to include it in lots of Liferay Portlets, in WEB-INF/lib
如果我测试的独立项目,从Liferay的Tomcat的JRE运行,一切正常,而 Desktop.isDesktopSupported()
收益真正。
If I test the standalone project, running from the Liferay's Tomcat jre, Everything works fine, and Desktop.isDesktopSupported()
returns true.
当一个Portlet,部署在同一Tomcat ,调用相同的库函数,在 Desktop.isDesktopSupported()
收益假
When a portlet, deployed on the Same Tomcat, calls the same library function, the Desktop.isDesktopSupported()
returns false.
由于在这两种情况下,我使用的相同的Java环境,为什么我得到一个不同的行为
Since in both cases, I'm using the Same Java Environment, why am I getting a different behavior?
另外,如果你知道的另一种方式来打开浏览器窗口,而不是使用Desktop.browse,这将是很好的佳品。
Also, if you know an alternative way to open a browser window instead of using Desktop.browse, it would be nice to share.
推荐答案
不过不知道为什么它不是在的Servlet / PortletContext来工作。
Still not sure why it's not working in Servlet/PortletContext.
一个解决方法是打开与java.lang.Runtime中的操作系统浏览器,demonstated 这里
A workaround is opening the os browser with Java.lang.Runtime, as demonstated here
这篇关于2应用在同一个JRE,从java.awt.Desktop.isDesktopSupported得到不同的结果()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!