Java, HTML and Android application using the same ServerSocket server - java

Is it possible a web html site, android or iOS and desktop client to communicate together using Java Sockets (The server is using ServerSocket)?

you should use an implementation of websockets in the server, instead of pure serversockets, something like : http://jwebsocket.org/ and for the web clients use http://socket.io/ that is a very mature implementation of websockets.
like this you could use the same html that make that communicate with the server using websockets, for pages and also to android runnning embeded in phonegap.
hope it helps.

Related

Implement web socket local server in Swing application

I am not able to find any implementation of a WS or WSS web socket server created in a Java Swing desktop application.
I am planning to govern multiple clients using a local server, imagine chat room on a local LAN, but I do not wish to host/run Tomcat or Jetty etc to host the server, I want it to be a Java Swing application that I can copy paste on any machine to make it the server and it can have the same chat features.
UPDATE:
Found some very useful topic : Java - Send Message to all Clients
Will follow this.
I am no expert in this realm, but this might help…
Wikipedia maintains a list of WebSocket implementations, both client and server.
You may be interested in the open-source Atmosphere Framework. It supports working with WebSocket but I am not clear if it actually is a server implementation.
Perhaps check open-source projects like Tomcat or Jetty or WildFly to see if their WebSocket implementation might be modularized sufficiently to plug into your app.

Connect two GWT applications - Client/Server

What is the best way to connect two GWT applications, a web (Client) and a mobile Application (Server with GWT Mobile).
I tried to do that with RPC but it has not worked.
The database is in the server part.
Any idea ?
Thanks in advance
Well the easiest way if you ask me is to use REST instead of gwt rpc.
Please take a look at RestyGWT for your GWT-client application, on server - any JAX-RS implementation will do, We're using Glassfish Jersey on a tomcat - works like charm.

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

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

Communication between Desktop Java & Web Application eg. PHP

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

Categories