Calling an external application (i.e. Windows Calculator) in a GWT web application

寵の児 提交于 2019-12-02 04:36:32

You cannot do it. Browsers do not allow access to executable files on a user's computer. It would have been a dream-come-true for every hacker out there.

A webapp should not and can not call a local program..

GWT compiles client classes to javascript and there's no support for Runtime, so GWT doesn't know how to transform your Runtime usage to JS.

For a list of GWT supported classes (client side), see http://www.gwtproject.org/doc/latest/RefJreEmulation.html

I see. Thanks for the answers guys. I'm still a newbie in GWT. Your answers helped me understand more about GWT and how it compiles classes to javascript as well as the idea behind why webapp should not be allowed access to local resources. However, I think there are still exceptions though depending on the need and scenarios; in my case, my webapp is only used and accessed in a closed group/network and not for public/anyone's use.

For anyone who is also interested, What I did is I created a javascript code that uses an ActiveXObject implementation to run the external apps, in my case a windows calculator. Then using this code, I run this in an IE browser since only IE fully supports ActiveX implementation.

I haven't tried Braj's suggestion above but I think it's also one alternative that will work. Maybe I'll try playing with that approach this weekend.

Braj

Use Java Applet to call an external application in GWT using JSNI.

Please have a look at below links for sample code.

Invoking Applet Methods From JavaScript Code

Call Java Applet function from Javascript

How to call Applet method from javascript

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