Which Platform Should You Choose for Developing Java Desktop Applications?
1. Introduction
In fact, there are some common questions with Java:
- What solution should I choose to programme a Desktop application?
- Is there any solution for programming a website whose interface is alike Desktop application's?
Trong tài liệu này tôi sẽ trả lời tổng quan về câu hỏi trên đồng thời có các giải pháp giúp bạn làm được điều đó.
Desktop Application:
This is a desktop application written in Java Swing:
Web Application:
And this is a Web application whose interface is alike a Desktop application's, and it is written on Eclipse RAP:
2. Programming Java Desktop Application
In fact, to programme a Desktop application you have 2 choices:
- Use Swing - is a integrated library available on JDK and able to run on every different operating systems (Window, Unix, Mac OS,..)
- Use SWT - is a library for programming Desktop applications and is developed by IBM. It is able to run on every different operating systems (Window, Unix, Mac OS,..)
This is an image of a Desktop application written with SWT and run on different operating systems.
This is an image of a Desktop application written with Swing. With a default "Look And Feel", it seems foolish. In programme, you can choose another L-A-F to get an interface similar with Windows or Linux if you want.
Swing
AWT (Abstract Window Toolkit) - is a library package developed for Desktop programme available in JDK. However, regrettably, it does not work as well as expected on different operating systems. This is the reason why Swing was born and replaced AWT in order to ensure that it runs well on different operating systems.
Swing builds graphical interface totally by Java and runs on every operating system. It does not replace AWT, but inherits from AWT instead. This is its weakness that makes programmers confused. A large number of classes owned by AWT have not been used, or become classes inherited by Swing's classes. In my opinion, this makes Swing is not appreciated.
SWT (Standard Widget Toolkit)
SWT (Standard Widget Toolkit) is a programming library for Desktop applications developed by IBM. It does not totally develop graphics with only Java. When running on an operating system, it manages to make use of graphical interfaces of that operating system (Button, Label,...) and creates only component graphics that has not existed in that operating system with Java.
When programming SWT, you should choose Eclipse IDE for the best. Eclipse can integrate with WindowBuilder plugin to help drag and drop interface components easily. WindowBuilder used to be a commercial product, but now it is free when integrated with Eclipse.
Compare SWT and Swing
Swing is a pure Java library. After you finished programming the application, you can set up Look And Feel to get an interface similar to Windows or Linux or Mac Os. Some Look And Feels are available on JDK, so you can use or buy L-A-F. Thus, you run a Swing application on the Windows platform on which display interface belongs to Linux, Mac Os,...
This is an introduction link of pretty L-A-F:
SWT - This library is not written completely by Java. When running on an operating system, it tries to make use of component libraries of that operating system (for example, it makes use of Buttons, Labels, Frames, etc) and only use Java for drawing components if they are unavailable on the operating system. Therefore, as for speed, SWT is faster than Swing.
To SWT, we don't have the concept of Look And Feel as to Swing. When you run the application on the platform of any operating system, the interface is characterized by that operating system.
Compare application performance:
You should choose SWT or Swing?
I think that you should choose SWT for programming a Desktop application because it is a library package with a plentiful supply of different interface components. Moreover, it was born after Swing, so it is the result of studying and remedying weaknesses of Swing.
SWT with expanding library packages is being developed, for example:
Eclipse develops a new platform named as RAP (Remote Application Platform) - RAP allows you to programme applications whose interfaces are alike Desktop applications' and which use familiar classes in SWT. Thus, you can write an application which can run both on the web platform and Desktop one. This is a strength if you choose SWT.
Let's see a Demo program written with RAP:
3. Eclipse Technology
We need to have an overview of technology of Eclipse
RCP is a Platform based on SWT library for programming Desktop applications . Running on different operating systems.
(More details RCP below.)
(More details RCP below.)
RAP (Remote Application Platform): is a Platform using RWT library for programming applications running on Web like the Desktop application.
- RWT (RAP Widget Toolkit) is a library package whose classes' name is the same as SWT' s. It has similar methods helping you programme RAP applications running on Web. Thank to this characteristic, with only a source code, you can run the application on the Desktop platform or Web one.
RAP runs well on different browsers.
Tabris - is a library package writing Mobile applications, and able to operate on different Mobile types.
4. RCP do what?
RCP (Rich Client Platform): A Platform using SWT library for programming Desktop applications . Running on different operating systems, It is a platform created Eclipse IDE
So RCP is a Platform using SWT as the basis of building. You can use RCP Platform to programme Desktop applications.
The below image illustrates a simple application (Only use SWT, but not advanced things of RCP Platform):
Platform RCP has built a platform allowing you to programme complicated structural interfaces like IDEEclipse. It includes the systems of Menu, Toolbar, View, Editor,...
RCP also allows you to develop Plugin integrated in Eclipse that you are using.
5. RAP do what?
RAP (Remote Application Platform): is a Platform using RWT library to programme applications running on Web like applications of Desktop.
- RWT (RAP Widget Toolkit) is a set of library with classes whose names are the same as those of classes of SWT and whose methods are similar. This helps you programme RAP applications on Web. Since this feature needs only 1 source code, you can run the application as an application of Desktop or on Web.
Like RCP, RAP is a Platform which allows us to create applications whose interfaces are as complicated as those of Eclipse IDE.
6. RAP and RCP - Why is the same code?
This is the structure of two Platform:
- RCP based on SWT (Standard Widget Toolkit)
- RAP based on RWT (RAP Widget Toolkit)
This is an example of code to add a Button to a Composite:
** MyApplicationWindow **
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
public class MyApplicationWindow {
.......
protected void createContents() {
.......
Composite composite = new Composite(shell, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
Button btnMyButton = new Button(composite, SWT.NONE);
btnMyButton.setText("My Button");
}
}
Both SWT and RWT use org.eclipse.swt.widgets.Button class to create a button.
Code of Button class of SWT (run on desktop) is obviously different from code of Button class of RWT (inherently run on WEB).
Code of Button class of SWT (run on desktop) is obviously different from code of Button class of RWT (inherently run on WEB).
- Button class of SWT is packed in jar file named org.eclipse.swt_*.jar
- Button class of SWT is packed in jar file named org.eclipse.rap.rwt_*.jar
Target Platform is a library environment where you can declare.
You can declare two Target Platforms. One includes RCP libraries, and another includes RAP libraries.
Of course, RAP and RCP have some differences. No all components of SWT have equivalently on RWT, and vice versa. In specific situations, we can handle this difference. Applications which can run on both Desktop and Web are known as "Single Sourcing".
You can declare two Target Platforms. One includes RCP libraries, and another includes RAP libraries.
- RCP Target Platform
- RAP Target Platform
Of course, RAP and RCP have some differences. No all components of SWT have equivalently on RWT, and vice versa. In specific situations, we can handle this difference. Applications which can run on both Desktop and Web are known as "Single Sourcing".
7. You should start from?
If you choose RAP-RCP programming, you will have to study SWT. This means you can easily learn about RWT.
Working with SWT means working with Widget objects (Button, Label,...) and handle Layout. WindowBuilder is a Plugin allowing us to drag & drop components on the interface and automatically generate equivalent codes.
Working with SWT means working with Widget objects (Button, Label,...) and handle Layout. WindowBuilder is a Plugin allowing us to drag & drop components on the interface and automatically generate equivalent codes.
You can reference the following document that instruct you to program SWT with WindowBuilder which is a visual tool helping drag & drop interface components easily.
After you have been fluent in programming with SWT, you can continue with RCP or RAP.
SWT:
RCP
RAP
Eclipse RAP
- Package and deploy Eclipse RAP application
- Eclipse RAP Tutorial for Beginners - Basic Application
- Install RAP Tools for Eclipse
- Which Platform Should You Choose for Developing Java Desktop Applications?
- Eclipse RAP Tutorial for Beginners - e4 Workbench Application
- Install Eclipse RAP Target Platform
- Eclipse RAP Tutorial for Beginners - Workbench Application (OLD)
- Create Eclipse RAP Widget from ClientScripting-based widget
- Install RAP e4 Tooling for Eclipse
Show More
Eclipse RCP
- Which Platform Should You Choose for Developing Java Desktop Applications?
- Programming Java Desktop Application Using SWT
- Eclipse RCP 4 Tutorial for Beginners - e4 Workbench Application
- Package and Deploy Desktop Application SWT/RCP
- Eclipse RCP 3 Tutorial for Beginners - Workbench Application
- Install e4 Tools Developer Resources for Eclipse
- Simple Eclipse RCP 3 Application - View and Editor integration
Show More
Eclipse Technology
- How to get the open source Java libraries as OSGi(s)
- Install Tycho for Eclipse
- Java OSGi Tutorial for Beginners
- Create Java OSGi project with Maven and Tycho
- Install WindowBuilder for Eclipse
- Which Platform Should You Choose for Developing Java Desktop Applications?
- Programming Java Desktop Application Using SWT
- Eclipse JFace Tutorial with Examples
- Install e4 Tools Developer Resources for Eclipse
- Package and Deploy Desktop Application SWT/RCP
- Install Eclipse RAP Target Platform
- Install EMF for Eclipse
- Install RAP e4 Tooling for Eclipse
- Create Eclipse RAP Widget from ClientScripting-based widget
- Install GEF for Eclipse
- Eclipse RAP Tutorial for Beginners - Workbench Application (OLD)
- Eclipse RCP 3 Tutorial for Beginners - Workbench Application
- Simple Eclipse RCP 3 Application - View and Editor integration
- Eclipse RCP 4 Tutorial for Beginners - e4 Workbench Application
- Install RAP Tools for Eclipse
- Eclipse RAP Tutorial for Beginners - Basic Application
- Eclipse RAP Tutorial for Beginners - e4 Workbench Application
- Package and deploy Eclipse RAP application
Show More
Java Basic
- Customize java compiler processing your Annotation (Annotation Processing Tool)
- Java Programming for team using Eclipse and SVN
- Java WeakReference Tutorial with Examples
- Java PhantomReference Tutorial with Examples
- Java Compression and Decompression Tutorial with Examples
- Configuring Eclipse to use the JDK instead of JRE
- Java String.format() and printf() methods
- Syntax and new features in Java 8
- Java Regular Expressions Tutorial with Examples
- Java Multithreading Programming Tutorial with Examples
- JDBC Driver Libraries for different types of database in Java
- Java JDBC Tutorial with Examples
- Get the values of the columns automatically increment when Insert a record using JDBC
- Java Stream Tutorial with Examples
- Java Functional Interface Tutorial with Examples
- Introduction to the Raspberry Pi
- Java Predicate Tutorial with Examples
- Abstract class and Interface in Java
- Access modifiers in Java
- Java Enums Tutorial with Examples
- Java Annotations Tutorial with Examples
- Comparing and Sorting in Java
- Java String, StringBuffer and StringBuilder Tutorial with Examples
- Java Exception Handling Tutorial with Examples
- Java Generics Tutorial with Examples
- Manipulating files and directories in Java
- Java BiPredicate Tutorial with Examples
- Java Consumer Tutorial with Examples
- Java BiConsumer Tutorial with Examples
- What is needed to get started with Java?
- History of Java and the difference between Oracle JDK and OpenJDK
- Install Java on Windows
- Install Java on Ubuntu
- Install OpenJDK on Ubuntu
- Install Eclipse
- Install Eclipse on Ubuntu
- Quick Learning Java for beginners
- History of bits and bytes in computer science
- Data Types in java
- Bitwise Operations
- if else statement in java
- Switch Statement in Java
- Loops in Java
- Arrays in Java
- JDK Javadoc in CHM format
- Inheritance and polymorphism in Java
- Java Function Tutorial with Examples
- Java BiFunction Tutorial with Examples
- Example of Java encoding and decoding using Apache Base64
- Java Reflection Tutorial with Examples
- Java remote method invocation - Java RMI Tutorial with Examples
- Java Socket Programming Tutorial with Examples
- Which Platform Should You Choose for Developing Java Desktop Applications?
- Java Commons IO Tutorial with Examples
- Java Commons Email Tutorial with Examples
- Java Commons Logging Tutorial with Examples
- Understanding Java System.identityHashCode, Object.hashCode and Object.equals
- Java SoftReference Tutorial with Examples
- Java Supplier Tutorial with Examples
- Java Aspect Oriented Programming with AspectJ (AOP)
Show More
- Java Servlet/Jsp Tutorials
- Java Collections Framework Tutorials
- Java API for HTML & XML
- Java IO Tutorials
- Java Date Time Tutorials
- Spring Boot Tutorials
- Maven Tutorials
- Gradle Tutorials
- Java Web Services Tutorials
- Java SWT Tutorials
- JavaFX Tutorials
- Java Oracle ADF Tutorials
- Struts2 Framework Tutorials
- Spring Cloud Tutorials