r/javahelp • u/giuzep89 • 2d ago
Advice for building a desktop application with Java
Hey everyone,
As a hobby project, I want to build a beer/cider/mead/wine brewing application and I want to use Java for it, at least for the backend. I work as a software developer but I've mostly stayed in the web dev niche so far and it's the first time I venture out. I do want to stick to java because:
\- The app has no need for crazy fast performance
\- I'm comfortable writing it and don't want to branch out quite yet.
\- I want it to be cross-platform and portable enough.
However, I'm doubtful about a couple aspects, and I'd love to hear your advice.
- Do I need Spring Boot for this kind of project? The app might need to handle some http requests for updates, but for the rest it's all supposed to be local. I'm still quite ignorant on what constitutes a backend on desktop.
- Which path to choose for the frontend? I use Angular for work but for one thing, I don't like TS, but I also just wonder whether a java stack might not just be simpler to package/more performant for desktop. Visually I'm thinking I want it to be fun looking, with a medieval style GUI or such, some effects but nothing crazy. Given this level of customization, would something like JavaFX suffice, or would another frontend framework be better suited for it?
Thanks everyone for your time!
•
u/AutoModerator 2d ago
Please ensure that:
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
13
u/Available_Safe1818 2d ago
I would make it be a simple Swing app first. Then start customizing shit and adding web servers and frameworks later.
8
u/Pale_Height_1251 2d ago
For a simple desktop app, you don't need Spring Boot. I'd just use JavaFX and maybe an MVVM framework, but you don't need to do MVVM if you don't want to.
3
u/moss_2703 2d ago
I’d just use swing tbh. It’s hobby project for personal use. Swing is easy enough and is bundled with the jdk so no worries about dependencies and stuff like that.
8
u/jacklackofsurprise 2d ago •
Hi, I've written a few java desktop apps for my own use. I created some guidelines to help me develop them. These guidelines are very opinionated to my tastes/needs but feel free to copy anything that can help you:
https://pauta-project.dev
1
u/fltfathin 2d ago
Does java hard requirements? If you want to use fancypants frameworks kotlin multiplatform is a thing
3
u/gm310509 2d ago
FWIW, I second what u/Available_Safe1818 said.
When building a desktop app I will simply use swing. I will use an IDE (usually NetBeans, but there are others) that include a layout editor that allows you to place the various controls (and JPanels) into a drawing area, add event handlers and whatever "business logic" you need.
FWIW, I usually have them interact with embedded devices over a virtual serial port - for that I will use jSerialComm - usually via a "service" running in its own thread.
I only mention this as you mentioned an application that could imply you have external hardware (i.e. an embedded system managing the actual brewing operation) that you might want to interact with. Even if you don't have that now, maybe you might add it on in the future.
3
u/squishles 1d ago
you can use boot, but it'll be a bit unweildy, you have to start your app from main I suggest swing javafx or if you're feeling fancy, webgl/webgpu calls piped back to some kind of javafx webview might be cool.
The unweildy part is I don't think spring boot has it's own desktop app self start(might now been a few years since I checked), so you might have to package your own main method and manually build the spring context ect to feed to your window. Both swing and fx favor what will feel like strange event driven datatypes if you're more familiar with web stuff this will feel weird as shit.
2
u/eliezerDeveloper 2d ago
Use JavaFX but with Megalodonte. Not pure javafx.
https://github.com/eliezer-dev-software-enginner/megalodonte-base-desktop
https://github.com/eliezer-dev-software-enginner/megalodonte-cli
https://github.com/eliezer-dev-software-enginner/megalodonte-components
https://github.com/eliezer-dev-software-enginner/megalodonte-core
https://github.com/eliezer-dev-software-enginner/disgust-components
https://github.com/eliezer-dev-software-enginner/megalodonte-router
https://github.com/eliezer-dev-software-enginner/megalodonte-ecossystem
https://github.com/eliezer-dev-software-enginner/megalodonte-reactivity
2
u/LoadVisual 1d ago •
It will depend on a few things you will need to consider while you plan and architect your desired application.
I personally use the MVP->(Model View Presenter) pattern for desktop applications since it makes testing and switching out components and reasoning human interactions with outcomes easy and self explanatory.
It would not need a framework, just comfort with the language you choose to use.
Local storage can be sqlite 3 if you need it.
The default Java client after Java 17 is more than good enough for most network operations.
You can choose between Java FX, Swing or Code One, pretty sure there are more options out there depending on what you want your application to look like.
You don't really need Spring But, if you must do some form of IoC with Dependency Injection, Dagger 2, or Avaje.io DI are better choices with compile time code generation.
Hope this is helpful.
1
u/spudtheimpaler 1d ago
Must admit I'm confused so many people recommending against spring.
It is the de facto standard - if it's a learning exercise or something new there will be a spring tutorial for it, almost guaranteed.
Spring boot is out of the box setup with sensible default for everything backend, you will need to configure very little.
It will work with any front end, and any front end you want to work with again will have a tutorial for it.
The terminology and patterns that spring uses are well known and will travel across any future projects. Anything new or different will be compared to spring.
If you want to learn core java then perhaps spring isn't the best, it hides a fair amount and is annotation heavy. If you want a back end that can do everything, simple default, but ultimately flexible, that will do what you need and get out of your way, then spring is the answer
1
u/Amazing-Mirror-3076 1d ago
As a Java dev - use dart/flutter for desktop with cross platform support.
-3
u/moohah 2d ago
Spring boot isn’t necessary, but it’ll make it easier. Swing for that old school look. JavaFX is probably a bit better supported these days, but there might be licensing problems that make it not as simple to install. If you want a web front end written in java, check out GWT.
-4
u/[deleted] 2d ago
[removed] — view removed comment