WebSwing – Swinging Java the Java Desktop into a Web Browser

I started my career working with ERP and accounting systems. Back in the 1990s I was heavily involved in the family business where I authored the accounting system for the business while doing the “day job” of running a development team with a software house.  Although the family business ended when my father retired, I have carried on writing “Cash Accountant” which I use for my own accounts as well as a few friends.   The current incarnation was created in the mid noughties comprising of a Swing Client with a  Spring web service/MySQL backend.   In recent years my professional career has been focused around Agile consultancy and Engineering Management which means I not a full time developer. Cash Accountant has enabled me to keep my hand in as a coder and gain practical insight with tools and new Java features, aiding the day job.

A few years back I really wanted to run the Swing client in a browser.  Cash Account has a lot of functionality which would make it difficult to recreate as a web application (time to write as well as learning how to create a Angular/Vue/React based front end).  My Swing client uses the Swing Desktop with multiple current opening windows etc.   I knew it was possible to run Swing apps in a browser as while consulting with UK’s MoD I had seen a supplier showing a Swing app running in a browser.  After a bit of “Googling” I found WebSwing 

Getting the Swing Client running was relatively straight forward with a working app in an afternoon.  Productionising the package took longer as I needed to create a custom webswing.sh start and stop WebSwing, create user accounts and add certificates to allow HTTPS connections.  A little more work allowed me to create a container version of WebSwing with my application (with separate containers for the backend and database servers) with these being built via a set of Jenkins jobs.

When WebSwing added JavaFX support I started to update my Swing Client with JavaFX windows.  The first “try-out” was a simple FX web browser – I still find it amusing to run Cash Accountant in a browser, open a JavaFX browser in the App and browse the internet!   FX works well in my App, and that includes the custom FX text editor created to allow input of masked values. 

The only downside, the version of WebSwing I am using enforces JDK11 (I have not checked the latest version  yet), my backend Spring code is using JDK14.  Fonts and general look and feel can also require a bit of tuning.    Although not under any significant load, my App is running 24×7 and has never failed due to WebSwing crashing etc.

Despite all the advances in web development, complex front ends are difficult to create as webapps, requiring highly skilled engineers for both back and front-end code.  Granted, JavaFX is niche but is supported by a group of professionals. When combined with WebSwing, sophisticated applications can be built traditional Java engineers, deployed as desktop or browser-based solutions which increases market reach and appeal while reducing development and deployment costs.    That appeals to me as an individual developer, but I would also find this an alluring if pitched by one of my product teams.