質問

I would know if there is a way to make a Java desktop application to communicate with an applet, in order to call Javascript functions from the desktop app (through applet).

The context :

In one hand, I'm having an ExtJS application (full-AJAX), which is located on a remote server. In the other hand, a desktop Java application (netbeans application), which is resident (indeed).

What I would do :

Each time one of the apps is used, it sends events & data to the other app.

After a few research, I saw interesting posts here and here, and also an answer on how to communicate between applets (see also here).

The question is not about how to do cross-domain from the applet to the destktop app (see over there and here), but as said in the beginning how to communicate from a desktop java app to the javascript.

Notes

The webapp (ExtJS) is based on a remote server, the applet too. I can locate the applet locally, but it implies to deploy a local webserver.

The desktop app is very heavy, so I cannot convert it in an applet format.

I put the "reverse-AJAX" tag because it is the global concept of what I would do.

If all this is possible without an applet (no Flash please), it's okay too.

役に立ちましたか?

解決

In order to call javascript methods from a Java applet in a browser you need to use the Netscape LiveConnect API, there are some examples here.
Basically this is an API that is implemented natively by the browser and allowed a java applet to access the javascript engine of the browser.

Once you have that sorted then you need to call methods in applet from the desktop application, this is a little more tricky. The most easy way would probably be to have an Enum that you exchange serialised instances of to describe the type of event.

There is an example of using sockets for communication here.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top