0

I've in the past created client-server web applications using Javascript, AJAX, Node, Express and MongoDB, but now I'm required to creare a client-server desktop application. It will therefore basically consists of a desktop program which will connect to a server program by doing requests. The server program will respond to the client program with the requested data which it can fetch from the database.

Since I'm really new to these kind of applications in Java, I have no idea how to create such an application in Java. Since the project will be large, we cannot hard-code all the server. We need probably a framework on the server side that listens for requests, but I've not found any for now. For example, Play Framework seems only to work for web applications. Which frameworks are useful for these purpose? Is this the right approach for this kind of applications? How would I connect client and server applications?

Please, do not suggest "use sockets". This will be quite a big "serious" project, and we need high level tools. We don't know how usually these kind of projects are created. Please, explain a little bit which patterns are usually used. Examples of concrete programs, maybe with open source code will be useful for us to understand. Also a list of the requirements that we need for these project would be very useful.

Note: I'm not asking for a exhaustive list of frameworks that we can use. I rather asking which kind of tools (with concrete examples) should we use and how to combine them. How to structure such a project.

nbro
  • 15,395
  • 32
  • 113
  • 196
  • 1
    Use a web server, which you can execute http `get`, `put` and `delete` commands to a which the web server will respond with XML or JSON ... AKA a web service. This affords you the functionality of a "normal" web server, the design and security that it brings and decouples your UI from it, so you could use a desktop app, mobile app or web app to access it – MadProgrammer Mar 04 '16 at 00:46
  • @MadProgrammer Interesting this part of decoupling the server side from the client side (i.e. indeed our application is initially requested to be a desktop one, but it eventually could move to a mobile and web one). Do you have concrete examples of web servers used in the Java world? The part of the fact that we need to do HTTP requests for me it's clear, but the problem is really to have concrete examples of tools and applications created that way, so that we can have a look at those and understand their structure. – nbro Mar 04 '16 at 00:50
  • Me personally, I use [Apache's HTTPComponents](https://hc.apache.org/) API to access things like the TVDB, TMDB, Melbourne Public Transport services and host of other web services, but you can get away with just using plain or `java.net.URL`. You could have a look at github for some examples of libraries written to access these services – MadProgrammer Mar 04 '16 at 00:53
  • nbro, you could implement the backend server in J2EE which is a spec for java web applications. This would allow you to connect the Java client to the Java based server, using web technologies like Mad has suggested. – RenegadeAndy Mar 04 '16 at 00:53
  • @MadProgrammer Do you know of a good example where the source of both client and server applications are public available so that we can understand a little bit how to structure such applications? – nbro Mar 04 '16 at 01:01
  • @nbro Not really. Maybe have a look at github? – MadProgrammer Mar 04 '16 at 01:04

1 Answers1

1

You could write the server side application in Node JS or whatever other server side language you prefer - and implement that using REST services. Then in your Java desktop application, it would just communicate with the server using HTTP REST / SOAP etc.

That way if you were to then want to swap to use something like .NET to make your desktop application you would be free to do so without it changing anything on the server side. Also you would be able to implement a mobile application / tablet app / other web application and reuse all of the server side implementation easily without changing anything server side.

Another option is to use ServerSocket for the Java server side, and then connect to that from the client but you seem to know and dislike that option.

Another option to connect each side of the application would be to use some kind of pub / sub middleware messaging service - check out JMS as a framework - you will need some kind of implementation of JMS such as Active MQ, Websphere MQ or one of the many other free implementations. Check out : http://docs.oracle.com/javaee/6/tutorial/doc/bncdq.html

Difficult question to answer, but those are 3 high level options.

  1. Use web technologies to connect client to server HTTP REST, or SOAP
  2. Use ServerSockets and Socket connections and do everything manually
  3. Use a messaging framework such as JMS
RenegadeAndy
  • 5,440
  • 18
  • 70
  • 130
  • Sorry, I forgot to mention. The server and client-side programs should be both written in Java. – nbro Mar 04 '16 at 00:51
  • No problem nbro, you could use the Java Spring framework for the backend : https://spring.io/ or you could write the Java web based backend to give you flexibility for the consumer of the backend server as per my answer above. You could do that by making a Java EE application. – RenegadeAndy Mar 04 '16 at 00:55
  • So, in a few words, what exactly would Spring help me in my case? Would it be like Node + Express to listen for requests and interacting with a database? How would the client implementation be eventually independent from the server side code (which would use Spring)? How would these two interact? I really would like to see a concrete real world example.. – nbro Mar 04 '16 at 01:05
  • Spring would be a framework which would do some of the heavy lifting of database integration with your business logic running in Java. It basically lets you concentrate more on the behaviour of your server side logic rather than configuration etc. The spring framework would expose the logic as restful services, or soap web services, so your client, whether its java desktop, android mobile, ios mobile or a web page itself, can make web based calls to the server side logic If you are looking for a real world example nearly every company uses this kind of organisation for their systems,google it. – RenegadeAndy Mar 04 '16 at 04:24