Which API to use for Java Desktop applications

-2

I'm wanting to develop a Java Desktop project and would like to analyze what would be the best API for this. I'm needing something like the state of the art desktop APIs for Java. I've done a search and found more references to Electron, which is an API that allows you to use a container embedded in the application so that it is not exposed in a browser. I do not know if it is the only option (I only found this current, JavaFX and SWT seem to be out of date), so my questions are:

  • Which APIs for Java are currently recommended for Desktop applications?
  • Pros and cons of these APIs
  • asked by anonymous 17.06.2018 / 04:41

    1 answer

    5

    The truth is that no API for Java on the desktop has gained much momentum. Java on the desktop has always been behind competitors, always being restricted to a niche.

    There are not many APIs for Java on the desktop out there, but there are a few:

    • Electron - A very rich API, but it has nothing to do with Java, but JavaScript. It uses a built-in Chrome implementation underneath the cloths. The advantage is that to work with it, you use the same technologies to develop on the web: HTML, Javascript, CSS, Ajax, etc. The downside is that it will go up a whole browser underneath the cloths, which tends to consume much more memory, processing, battery and disk space than most other solutions, since Chrome is not exactly known for trying to save money these resources.

    • AWT - This is the first desktop API that has come to Java, existing since Java 1.0 for over 20 years, so it is supported everywhere that Java has desktop. It has some old components, but most of them (but not all) are obsolete. Some of those that are not obsolete are used as the basis for both Swing and JavaFX, while others serve as an escape valve for things that Swing and JavaFX do not. There are two important parts here: components like java.awt.Button are obsolete (although they do not have a @Deprecated annotation in them), while base components like java.awt.Window are still in use today. Its components are implemented through connections to native components (made available through the operating system). No one recommends using the AWT components directly. In my opinion, his API is awful and hard to use.

    • Swing - This is the default API for developing desktop applications in Java. It is said to be the replacement for AWT, but that's just a half-truth. In fact, Swing runs over the AWT. While in AWT, components are implemented natively by the operating system, Swing uses the approach of deploying components entirely in Java, which makes them quite flexible. However, I find Swing has a cumbersome, confusing, hard-to-use, hard-to-learn, and extremely verbose API, and that was the main reason why Java never gets popular with deskop. Another problem is that Oracle has little interest in investing in desktop development, and for that reason, do not expect too much news with Swing.

    • JavaFX - Another API added with the intention of replacing the previous one (in the case of Swing), but that actually makes use of the previous one. JavaFX runs over Swing, so this idea of replacement is another half-truth. I do not have a lot of experience with it, but in the little I've used, it tends to be easier than doing the Swing equivalent, and it also tries to get a little closer to the common patterns of web development. However, it has the disadvantage of not having all the features that Swing gives you. Another thing to note is that Oracle wants get rid of it so that it continues to be developed independently .

    • SWT - A Java API created by the Eclipse foundation that is not made on top of AWT. It takes an opposite approach to Swing, and seeks to develop as many functionalities as possible natively to have the best performance possible, and for that reason is much less flexible than Swing or JavaFX. I have no experience with her, but the only time I tried to move, I gave up. It has little active development.

    • Liquid Engine - A modern API for creating graphical interfaces that is evolving fast, developed over OpenGL and the LWJGL. I do not know more details to talk about, but it looks promising.

    • jMonkeyEngine - An API for creating 3D Java games, developed over JOGL and OpenGL, but also allows you to create graphical 2D interfaces. I know very little about it.

    17.06.2018 / 06:21