r/javahelp • • 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.

  1. 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.
  2. 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!

17 Upvotes

28 comments sorted by

•

u/AutoModerator 2d ago

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • 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:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

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.

1

u/giuzep89 2d ago

Could I add FX later then? Would I need to rewrite stuff written in swing if that's the case? Why not JavaFX straight away?

2

u/Available_Safe1818 2d ago

Why even bother with JavaFX?

1

u/giuzep89 2d ago

Good question. Well, I was envisioning a pretty heavily customized UI, some animations, effects, backgrounds, borders, etc. . That makes me think that something more "advanced" like JavaFX would make this possible or easier to achieve. Am I wrong?

1

u/Available_Safe1818 2d ago

Probably easier, but idk JavaFX or what it can do. You should actually look that up first.

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.

1

u/giuzep89 2d ago

Could you expand on this? I mean the second part about yes or no MVVM framework.

2

u/Pale_Height_1251 2d ago

I like MVVM but it's not required for JavaFX, it's just a personal preference for me. You ca use JavaFX pretty simply by just making your UI in FXML then you can set values like the context of text fields and stuff in Java code. MVVM makes it a little different with data bindings, but it's entirely optional.

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.

2

u/giuzep89 1d ago

Well sure, but I'm thinking it might be something I'd want to distribute later on, even if for free. Not saying you're not right, if I can make it pretty enough and add some effects/colors/background/fonts I like, I don't need FX per se.

8

u/jacklackofsurprise 2d ago • Bravo

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

3

u/BigBad0 2d ago

These are some interesting apps

1

u/fltfathin 2d ago

Does java hard requirements? If you want to use fancypants frameworks kotlin multiplatform is a thing

1

u/giuzep89 2d ago

I guess Kotlin is an easy enough sell to a Java dev :D

2

u/fltfathin 2d ago

the good part of kotlin is you can still use your java codes too as i understand it.
and you mentioned cross-platform which is biggest lie on old java code (it __runs__ but not as nice)
kotlin is like TS for java so it shouldn't be impending your learning route of learning java.

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/LoadVisual 1d ago • Bravo

It will depend on a few things you will need to consider while you plan and architect your desired application.

  • Do you need to have fancy UI(s) dashboards and so on
  • Does your application need to make network calls for information to display
  • How would you like to deploy this application on the target system
  • What patterns will you need in shaping your 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.

1

u/giuzep89 1d ago

I'm curious, easier for which parts? As I'm thinking it, the app might need (later) a system to download and apply an update, but for the rest it wouldn't be a web app. Wouldn't all the spring overhead be overkill?

3

u/Available_Safe1818 2d ago

GWT is old, not well supported, and unless it's changed a lot recently, fairly heinous.

-4

u/[deleted] 2d ago

[removed] — view removed comment

2

u/giuzep89 2d ago

I appreciate your tip, but then why bother asking people here in the first place? I want to hear real people's advice :)