What are the options for migrating a networked Java desktop app to a web app

Go To StackoverFlow.com


I have a Java desktop app (with a Swing GUI) that runs in a LAN environment. Normally, I run it with a bunch of machines, some play the role of servers while others act as clients.

Now, I would like to run the same app on the Internet, where both the server and clients will be hosted on a website, so that visitors of the website will be able to run as the clients and interact with each other.

I wonder what are options are available for such migration? Do I need to re-write everything from scratch using some Java-based web framework? If so, how should I deal with the GUI part? Or do I just host the app as an applet? (somehow I am reluctant to go down the applet route, as it may require additional setup on individual visitor's machine I have no control of and there may exist compatibility issues). Thanks!

2012-04-04 19:05
by skyork


One option would be to use Vaadin. The programming mindset is quite close to JavaSE Swing. It is a GWT derivative on the client-side, but the logic is really on the server JVM and the framework takes care of the communication (xhr or web sockets).

2015-02-14 15:18
by quickanalysis


Google Web Toolkit (GWT) could be usefull for that since it will let you re-use generic Java code and compile it to JavaScript for running in the browser. In my app I am reusing classes in the client that I use in the server. The UI has to be recreated using web widgets though however wysiwyg tools exist for that.

You could also migrate your raw sockets to Websockets if you require bi-directional communication.

2012-04-04 19:07
by Andrejs
This sounds promising. Two main questions: 1. how smooth/useful is this translation of Java code into Javascript code by GWT? As far as I know, Javascript is still largely a front-end language for the web, so how do I handle back-end stuff such as writing/reading to/from the database? 2. what do you mean by bi-directional communication? Do you mean the two-way communication between clients and servers? Many thanks - skyork 2012-04-04 22:00
  • You write everything in Java all the time, GWT translates it to js when you deploy but you don't have to worry about that. Back end is still Java servlets so you can do any Java operations (db etc.). 2. Normally web apps make requests to servers and then get a response. If you need to stream data to your web app, you need websockets.
  • - Andrejs 2012-04-04 22:11


    If your code follows the mvc pattern it should be possible to reuse the model stuff. My favorite java web frameworks are those from spring source. Spring mvc (clean mvc design) or spring roo (more the rails style with code generation etc.). Both integrate well with the dojo framework (ajax / gui stuff).

    2012-04-04 20:35
    by hburde
    Thanks for the suggestion. I was looking into some newer frameworks such as Play. A major concern of mine is connectivity, which may be more volatile for such a web app than in a more controlled lab environment. Any suggestion of how to deal with that using this framework approach? Thanks - skyork 2012-04-04 21:52