Communication between Desktop Java & Web Application eg. PHP - java

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 ;)

Related

Possible to include Client JAVA API libraries in Web-services?

We want to develop a Java based Web-services (since the API's we want to use are Java based)
I would like to know if it's possible to use the IBM Rational Team Concert Plain Java API's (https://jazz.net/downloads/rational-team-concert/releases/5.0/RTC-Client-plainJavaLib-5.0.zip) as part of the Web-servicesand deploy them in the server?
Basically we use these API's on a client based Java applications. What I am looking at is more like a services which can be consumed by many applications
Anyone has any experience in deploying the client based API in the server as Web-services?
After multiple tries, it is possible to use the RTC Plain Java API's as Webservices.
How I did:
Followed the simple Webs Service creation tutorial (http://wiki.eclipse.org/Creating_a_Bottom-Up_Java_Web_Service)
Adapted to my needs
First added the "RTC plain Java API's (JAR's)" to the Eclipse build path
Then added the "RTC plain Java API's (JAR's)" to the "WebContent/Lib/" folder of my Dynamic web project
Created a new Web service & Web service client
I was able to login to RTC via this for starters

Embedable Java-based HTTP server with (PHP) scripting support

For my Java project I need to embed a web server to provide various web pages to the user. Until now we used the "official" com.sun.net.httpserver.HttpServer class, which basically works fine.
However, now we want to extend our application in order to not only serve static HTML pages via the embeded HTTP server, but also dynamic content (PHP if possible).
Any recommendations?
EDIT: Nevermind, I found it quite easy to integrate Jython within my Java application :)

Java : how to communicate from localhost Java desktop application to Java Applet?

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.

Developing Apps for iOS, Android and the Desktop

We have an existing distributed application used by a small company to manage their customers.
The server side component is deployed in the cloud as a simple Java app that manages a connection to a MySQL database.
The client side is implemented as a Java Swing application deployed using JNLP and communicates with the server side using RMI.
This has worked quite well for us so far, but recently we've been looking at how our customers could access the application from mobile devices, tablets (both iOS and Android) as well as from the desktop.
At the minute I'm thinking we should be looking into developing RESTful web services on the server side to manage access to the MySQL database. On the client side, we could use Googles GWT to provide a quick and easy solution for accessing the services from all platforms. Going forward we could implement native iOS / Android apps to access the web services.
Am I am the right track here? Does anyone have any better approaches? Does anyone have any recommendations as to what tools I should be looking at?
The key thing I am interested in is being able to access the server side from any platform. I really don't want to have to implement separate server side implementations for each
Sounds like you are on the right track with the RESTFul web services. If you go this route, you should be covered for the backend. As long as your frontend can do http requests and handle JSON data you will be fine.
Going forward we could implement native iOS / Android apps to access the web services.
It is possible to design a mobile app for deployment on both android and iOS, this could save time on the development effort. To do that you could use, for example PhoneGap, which creates an abstraction layer over the phone hardware, along with something like jQuery Mobile, in which the UI is developed in HTML5 and javascript, and the same code is deployed via PhoneGap on both devices.
PhoneGap: http://phonegap.com/
jQuery Mobile: http://jquerymobile.com/
if there is some other option that lets you deploy the same frontend on android, iOS, AND the desktop, i would go with that, so that you only have one code base for the frontend.
I think your solution (GWT/HTML5) client talking to a server-side "business" layer is a good multi-client solution. RESTful web services are unneccesary in the context of what you have described since the GWT implmentation would take care of the comms between client and server:
GWT client <---> Server (GWT) <---> Database
If you are using a different client implementation (such as iOS), then RESTful services will be very handy indeed (and you wouldn't use GWT):
iOS client <---> Server (RESTful endpoints) <---> Database
HTML5 is becoming provides a decent compromise between broad applicability (many clients) and rich client features. I have seen an article in the past about using PhoneGap and GWT together which sounded like a good strategy for working with GWT (which I like) and gaining access to device-dependent capabilities. All whilst working in an environment where you can (Java-)debug even client code (incredibly useful GWT feature).

How to build a web based chat application similar to gmail using java at backend logic

Hii,
I want to built a web based chat using j2ee at backend logic.i want to implement the similar way the gmail do,so that performance of application doesnr degrade.please suggest what type of architecture shoul i follow.load of application would be high.
Use what Google used: GWT. They spent years on making it fast and easy to use.
The Jetty web container has a demo chat application which uses Ajax as the gmail chat does and which is not too complicated to learn.
It appears somebody has a Jetty running on http://64.164.6.244:9090/test/chat/chat.html, so you can see what it looks like before downloading and running it yourself.

Categories