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.
Related
I have a web application (written using GWT) that used to load a Java applet in order to perform some tasks, such as writing/reading a file on a local filesystem and printing to multiple printers. Since Java applets are no longer supported in Chrome and are generally deprecated I need to find a suitable alternative.
My Web app should send and receive data from Desktop Java app. This communication should be implemented locally since it has to work even when client is offline (web app continues to work when user is offline).
I considered building a Chrome extension that uses Chrome Messaging API to communicate with Web app as well as Desktop app (pass data between them and act as a mediator). This can work but I am wondering if there is a cross-browser way of achieving this?
I've also considered building a web server inside Desktop Java app and then call http://localhost:port from the web app, but I'm not sure about possible negative security (and other) implications of this approach.
What would you recommend?
Thanks!
Since you use chrome, there is support for HTML5 Filesystem features.
For example as described here: http://www.noupe.com/design/html5-filesystem-api-create-files-store-locally-using-javascript-webkit.html
GWT supports no Filesystem access directly, only local browser storage. So you need to wrap it yourself or use the elemental.* api (http://www.gwtproject.org/articles/elemental.html) to gain access to the elements directly and wrap them into widgets.
You may find this discussion helpful as well: GWT Websockets with Elemental
I already have an Java application running on client site.
This application currently does not have any UI. What it does is just transforming data for the client behind the scene.
We need to regularly upgrade the application.
Now we would like to add a UI using GWT.
My question is
Can I include GWT directly into my current application, as a whole?
I mean, my current Java application start from main(). On client side, we just execute java Application (simply say). After we have our GWT part, we really want everything still the same. On client side, we don't need to let client or we ourselves install many new things.
So ideally, after we finish our GWT part, for client, still, our application is one application and the way to launch is only java Application
We don't want to tell client that we need a TomCat server to be seperately installed.
We don't want client feel troublesome and it seems now we need to maintain multiple packages, etc.
You need a web-server to serve you GWT application, orelse it can not communicate with local Java app. As you run GWT-compiled Javascript in a browser, it can't access to your local machine resources.
It can be a Tomcat running on localHost or you could use Google App Engine. You can't run a GWT app like a Java Swing application.
But relax... Tomcat is not that troublesome and does not require more package that what is already in it.
I have a java application which is a java web start application. It is used to administer a remote server. Now I want to convert it to an applet to run in the browser. Is there an easy way to achieve this. What are my options to achieve this? By the way my java application stores and reads some conf files on the client file system. Would this be a problem if I run my application as an applet?
That shouldn't be too hard since Sun/Oracle introduced JNLP support for applets in version 6u10 (1.6.0_10).
In short:
Adapt your app to the applet lifecycle,
set the permissions correctly and
sign it with an official certificate.
(and of course embedd your applet in a web page)
How do I connect my Java Desktop application with a PHP Web Application. Any example codes and technologies I should know of? I just want a simple implementation (its a school project and I don't have much time to perfect it)
On the web side, perhaps I can have a REST-ful API. But what about the Java Desktop side (I'm more of a web developer). How can I pull & pull data from my Java app?
You can create an http-endpoint in the desktop app as well. For instance you can embed a simple servlet container like jetty.
Once you have a servlet container, you can use something like Jersey to write a REST API (or you can just use the Servlet API).
Another option is to create a ServerSocket in the java app, and connect to it from the php app.
There is also a php-java bridge, if you want to get really fancy ;)
Is it possible to make a Facebook desktop application in Java without using a servlet?
I am developing a Facebook desktop application. I am very close to completion, but a problem comes in getting an access token.
I successfully opened a browser through my Java code, but I can't read the URL of the web browser. I don't want to use a servlet.
Yes it is possible to do that, check out the Authentication documentation, the part you are most interested in is titled Desktop Apps, and it says:
Our OAuth 2.0 implementation does not include explicit desktop app
support. However, if your desktop app can embed a web browser (most
desktop frameworks such as .NET, AIR and Cocoa support embedding
browsers), you can use the client-side flow with one modification: a
specific redirect_uri.
You can read more and see exactly how there.