Vue.js + Jersey desktop app
The other day, as an implementation example of a simple desktop application, vue-nest-desktop-app (Vue.js + NestJS for desktop application Implement), but backend development is more familiar with Java (Spring Boot + Jersey) than Node.js, so back I created vue-jersey-desktop-app with the end replaced with Java.
The following is a brief summary of development points.
Application configuration
- The backend is developed by Spring Boot. It is configured to build and distribute in an executable jar file (so-called fat jar) that incorporates embedded Tomcat, and access the locally started application server from a browser to use it.
- The front end is implemented with Vue.js, and the built HTML, CSS, and JavaScript are delivered as static files using the back end web server function (spring-boot-starter-web).
- The main function is provided as Restful API (spring-boot-starter-jersey) on the back end, and it is used by API call from the front end.
Spring Boot desktop application
The following measures have been taken to turn Spring Boot into a desktop application.
- Display the log in the window implemented by Swing so that the application will stop when the window is closed. (Because it is difficult to determine whether the application is running or stop the application just by starting the application in the background when the jar is executed.)
- Reference: ConsoleFrame.java
- The application server searches for a free port on the local machine and starts, and after starting, the system (default) browser automatically opens the top screen of the front end.
- Reference: Browser.java
Calling an external Restful API
Since the browser accesses the front end hosted by a locally running web server, it is not possible to directly access other external web APIs from the front end. Therefore, the API proxy function (also supports SSH port forwarding so that you can access the closed API for development) is implemented on the backend side.
Reference: ApiProxy.java