Java Development – Single Code Base for Desktop GUI and Web Application

guijavajvmweb-development

The required user interface is fairly simple; basically, two tables that "interact with each other", e.g. certain rows in one table get highlighted when a row in the other is clicked, plus maybe a panel with charts.

Is it possible to have a (largely) single code base for a desktop app and a web app implementing this interface? For a few reasons, it would be good to have both versions, but I would hate to implement the GUI twice.

The details of my particular case are as follows:

  1. This is an academic research problem, so I don't have strict constraints in terms of tools and the coding style (or users!). On the other hand, I do have quite some time constraints.
  2. It has to run on bare JVM, but any language/framework would be welcome (Java, Groovy, Scala, Clojure, etc.).
  3. There is no persistent state, i.e. no strict need in a shared DB or any server part whatsoever.
  4. I would be willing to go through some design hoops to make it work (by design hoops I mean some unconventional application architecture).

Is it completely crazy to even think about something like that? If no, what would be the tools to pull it off?

Best Answer

A browser is a desktop application, its very easy to pack your war with and embebed server (with jetty its really easy), this way you can run your app in a stand-alone machine.

If you want two versions, web and desktop, its because one of this versions gives things to your users that the other versions cannot give, if you are thinking in a "automatic" way of having the two GUI's its because you are thinking in having basically the same app in the browser and in the desktop version, ¿why you are thinking in wasting your time for building the same thing twice?

In resume, the problem its not thinking in an automatic way of having two guis, the real problem its thinking in why do you want this two versions in the first place.