2 apps in the same JRE, are getting different result from java.awt.Desktop.isDesktopSupported()

故事扮演 提交于 2020-01-05 08:56:30

问题


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.

I'm exporting that library in a .jar file, that I intend to include it in lots of Liferay Portlets, in WEB-INF/lib

If I test the standalone project, running from the Liferay's Tomcat jre, Everything works fine, and Desktop.isDesktopSupported() returns true.

When a portlet, deployed on the Same Tomcat, calls the same library function, the Desktop.isDesktopSupported() returns false.

Since in both cases, I'm using the Same Java Environment, why am I getting a different behavior?

Also, if you know an alternative way to open a browser window instead of using Desktop.browse, it would be nice to share.


回答1:


Still not sure why it's not working in Servlet/PortletContext.

A workaround is opening the os browser with Java.lang.Runtime, as demonstated here



来源:https://stackoverflow.com/questions/22557207/2-apps-in-the-same-jre-are-getting-different-result-from-java-awt-desktop-isdes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!