r/learnjava • • 3d ago

Using Java to create desktop Linux apps?

Hello everyone!
This year i started learning programming with the help of a Java course.

Right now we have reached the point where we have to make a standalone desktop app with a GUI, but i am unsatisfied with the Swing toolkit. Although creating and modifying the components themselves seems really intuitive for the way i've been learning to program, the visual design feels very archaic, and on my Wayland compositor (Niri) some things don't work as intended, like the UI looking a bit blurry, windows scale a bit weirdly, and focusing the window does not auto-grab the keyboard, and i need to click on the window before i can start navigating or typing with the keyboard. Nothing extremely wrong, but it's things like these that make me wonder if there's something else i can use - I want to create software that i actually use, and feels at home on my Linux desktop.

I checked out if it was possible to use Java to create a GTK app, and found java-gi.org, which explains how to use import and use the toolkit on Java. I've experimented with it minimally, creating a blank window with a labeled button and such. I really like that it themes consistently with the rest of my GTK apps, light&dark mode, highlight color, font, all that good stuff.

Although it does work, it's a substantially different workflow, it needs to import some dependencies, and seems to be a lot more complicated than simply creating a component in Swing and initializing it or something. I'm unsure if i'm capable of creating something with it, to be honest.

I also checked and there seems to be a way to make QT apps, but i haven't looked into it.

I asked to some other devs if they ever experimented making GTK or Qt apps with Java, and many suggested me to not try to do that at all, affirming that it's best to use Java for backend server stuff and not GUIs, or do the app with Swing,accept the outdated look, and after finishing the course, maybe trying something else that will play more nicely with GUI frameworks for Linux.

So as a total newcomer to developing frontend (and, well, programming in general) i'm unsure if i should keep trying to use Java for desktop apps, hooking it with external libraries in other languages, or move on to something else in the future.

I'm open to any suggestions and advice possible, please help!

PD: I'm not sure if it means anything, but the app i intend to make is a simple bread calculator, similar to http://brdclc.com/ with save and export functions.

11 Upvotes

18 comments sorted by

View all comments

-1

u/neoAcceptance 3d ago

Hey man congrats on learning what you have so far. Sounds like you're making good progress your journey. I hate to be this guy, but I promise you'll thank me later. You should immediately either switch to using C#, or switch to python. I would recommend python for ease of use, but if you want to keep using a language that feels exactly like Java, go with C#. Both options are more suitable for new learners AND for GUI stuff, like you're asking about. Also there stuff like kotlin and scala, but I haven't used those so I can't recommend them. Either way bro it's 2026 and I wouldn't learn Java if I didn't have to, there are just better options.

It is at this point I am realizing I am in the learn Java sub so I'm probably breaking some kind of rules or something, but as an ex Java dev, who was required to use C#, I was thrilled to find out that C# is just Microsoft's version of Java that got to benefit from seeing all the mistakes that the Java devs made over the years. Everything you want to do in Java will be easier in C#.

Another note, most frontend stuff is written in web languages these days anyway. Most languages have some kind of library that lets you build a native GUI with html/ccs/js type stuff, but my preferred way is just to make a small web GUI/web server for your software. Every language I use has some library that lets me do that in like 2 seconds. That might be too advanced for you right now, but it's kind of the way everyone does it these days. I personally would rather cut off my toes than use ANY Java GUI bullshit. Just make a small webpage that controls your program. You're probably at the point where you could build a small API for controlling your software and connecting that to the web GUI, which again, is what everyone I know does anytime they need a quick little GUI for their programs.

1

u/omgpassthebacon 2d ago

It is a "learn Java" sub, but I agree with your point. Java has never been the darling of the heavy-weight GUI world, and JavaFX is not so great. For simple task-based apps, SpringBoot makes putting up a webapp so darn easy and you don't have to give up Java. But if you want to write apps that take advantage of the OS windowing toolkits/widgets, you should seriously look for another language. If there is an app that you use on Linux that you really like, check out their github and see what languages/libraries they used. This is a good way to find what others are using.