J1001. Elementary Introduction to Java Native Desktop and web development

Source: Internet
Author: User

Since the advent of Java, the development of the service side has made great progress. However, in the desktop/web development, has not been greatly developed. From the initial AWT, to swing, to Javafx,java, there has never been an important seat in a desktop/web solution, let alone a dominant position.

Awt

The AWT (abstract window ToolKit, Abstraction Windows Toolkit) is the UI framework that Sun introduced in 1996. Because of the need for cross-platform, AWT can only support the interface components and features (intersection) common to the mainstream platform, such as tags, buttons, etc., which leads to the lack of the component richness and functionality of AWT. AWT is a heavyweight UI framework by creating a peer (peer component) corresponding to the operating system to display the components on the interface, and relying on the operating system's native methods for graphical functionality. That is, when we use AWT to build a graphical interface, we are actually invoking the function of the operating system graphics library, which has different performance on different operating systems.

AWT's heavy-duty UI framework, both historically and in the future, will only be used as an infrastructure and will not be a solution for desktop applications.

Swing

Swing is a UI framework built on the AWT basis, all written in Java. Swing provides lightweight, richer UI components, such as trees, lists, tables, and more, than AWT. AWT is based on an operating system native method, so it runs faster, and swing is an AWT-based Java program that is executed using an interpretation method. The interface that swing draws is consistent across different operating systems. Although Sun's launch of swing is a solution to the problems that AWT faces, it does not.

A lot of developers in China have been grumbling about swing, especially. NET and JS-based developers. Even though swing gracefully encapsulates AWT based on MVC, it has always been a cross-platform problem, resulting in the application interface of the swing fabric by default, which is not capable or necessary to implement complex lookandfeel. At the same time, swing has always had a usability problem, and without the visual support of an IDE like Visual Studio, a simple tabular interface would need to be handwritten n multiple classes in order to be patience, especially for beginners.

Native Java is rarely used in the country to develop Web applications, and it is estimated that there are few desktop applications. But swing has a certain market in foreign countries, especially some large hardware and software companies, such as IBM, Oracle and so on, their software cross-platform features are just needed, so we can often see some swing-based implementation of the installation program, management tools and so on.

In fact, swing can be beautiful and easy to use, as long as it has the technical strength and the willingness to pay for the resources and costs. For example, we use Eclipse, IntelliJ idea, UF NC6, and 2BizBox ERP system every day. There are third-party open source libraries such as substance, SWINGX, etc. that provide skins and UI components.

(: IntelliJ idea)

(: UF NC6)

(: 2BizBox ERP)

The above list is the representative of swing-based, cool desktop apps and web apps I've seen.

In contrast to desktop applications, swing's application in the Web confirms the sentence: No worst, only worse. For swing to be able to run in the browser, in addition to the most basic JRE, the applet is displayed in the browser as swing's display in the browser--applet, and swing is displayed in the applet. Applets can be displayed in the browser, based on the Netscape Company's NPAPI (Netscape Plugin application programming) technology, the company was the first to achieve browser commercialization, But has been the giant hard company with free ie to kill. Let's always have free browsers to use, which is one of the good things Microsoft has done, though it didn't mean it.

With the development of the Times and the progress of technology, people's demand for network security is more and more high, the security requirements of the browser are more and more high. Npapi this more than 10-year-old technology has clearly failed to meet today's requirements. Google Chrome has already disabled the JRE, and there is no known reason why Oracle has a huge amount of compensation for Google's claims based on Java, and Microsoft has elevated the level of the JRE in IE, which has previously been "low" and is now "high".

In fact, as far as I'm concerned, Sun was given the opportunity to try and even try to do something wrong with Java's web development-if it wanted to. It turned out that Sun had sold Java to Oracle. When it hardware companies have not been able to "sell services" as their own profit support, such as IBM, Sun, the software is for the hardware services, and even can buy my small machine to send you software.

To be fair, the main concept of the mainstream MVC framework, based on Java, is inextricably linked to swing. If the management system used as intranet, the network environment is guaranteed, allow some foreground UI classes to download to the client (in fact, I think this is an advantage, the application of the portal is through the browser, a bit of space in exchange for a relatively fast UI response speed, I think it is very worthwhile), There are advantages to using swing as an interface to show technology. Even in a WAN environment, swing can perform better if it guarantees a certain amount of bandwidth, rate, and security prerequisites for each client and server.

Sun has been absent-minded in developing Java desktop/web capabilities and has not substantially contributed to the improvement or re-enactment of Java-browser-related protocols and security standards. Instead, JavaScript, HTML5 and other scripting languages accompany with the development of the browser, and become the mainstream of web front-end development. From AWT, to swing, to JavaFX, the UI components they provide seem to solve the "no" problem, and not really stand up to the users, especially the enterprise application development perspective, to consider providing rich, useful components to solve the problem of rapid development. In the most common form, for example, Swing writes a bunch of code that, if not packaged by itself, is almost zero out of the box and reused. JavaFX should say that there are some advances in swing, but the data type, ease of operation, and the basic requirements of enterprise application development are still far from the need to write a bunch of tablecolumn, you need to handle complex data types and so on. Another example is swing's layout is too technical, ease of use is too poor, the expansion is too cumbersome. The more complex the interface, the more nonlinear the complexity of the code grows.

As shown in the above several interfaces, Java in the desktop development, to sun/oracle standards, I am afraid of what effect can be achieved, but from the actual developer's point of view, only "dog belt".

Neither pay attention to the agreement and standards, but also do not focus on ease of use, so that we do not write JS old programmers think of angry-wrote more than 10 years of code, suddenly found that they do not write the interface.

From the Java Desktop/web front-end development of the awkward position, can also be seen, the front-end is really bad.

UI-side framework of the technical implementation is not more complex than the server, but the server is mainly based on the standard container, CPU, memory, storage, network and other standard, normative infrastructure to deal with, and the UI end of the implementation of the operating system is constrained by the recount, it appears to be less prescriptive, so it seems more trivial, trouble. Interested students, you can take a look at the JLabel this basic swing interface component implementation code. Let's pay attention to a related class diagram:

Just a small number of major classes and individual interfaces, these classes, the source code more than 5K line is not uncommon.

Swt

The SWT (Standard widget Toolkit, standards widgets) is an open source UI component library from IBM that wants to address issues with AWT and swing applications. SWT is widely used, such as Eclipse, WebSphere installation program, Mat and so on. SWT provides a richer and better interface component and feature than swing, and as with AWT, SWT invokes the operating system local method through peer. At the same time, SWT accelerates the response time of the UI component by using the features of a particular operating system, so SWT needs to prepare the installation package for different operating systems, like AWT, without the Lookandfeel functionality of swing. Look at an IBM Mat interface:

Javafx

Sun launched JavaFX 1.0 at the end of 2008 years prior to Oracle's takeover, hoping Java would make a contribution to RIA (RIch Internet application). JavaFX 1.0 is a script that feels like a huge ugly person. Oracle launched a native Java refactoring-based JavaFX2.0 with JDK8 in 2011, abandoning the original JavaFX script mechanism. In 2014, JavaFX8 was released with JDK8, and JavaFX became part of the JDK.

For more information and features on JavaFX, refer to the Oracle website and related materials. Writing these articles and trying to develop an application framework based on JavaFX, mainly considering the following advantages of JavaFX versus swing and javascript:

1. JavaFX and JDK have been combined (specifically, JavaFX2.0 from JDK1.8), JavaFX can directly use all Java resources, including third-party libraries, which provides great convenience for development-no longer need to learn the syntax and features of the foreground framework like JS, Java is used from the UI side to the business implementation, and technology and experience are common, reducing learning costs, and developers don't have to split back and forth, and each developer can have the basic skills they have done in the past.

2, the JRE can be run, and sometimes this is a disadvantage, but in enterprise applications should be acceptable.

3. Provide a rich library of base components, such as ListView, TableView, HTML editor, etc., to design the UI base class and basic framework more conveniently.

4, provide a more rich, easy-to-use layout device. If there are no features such as Borderpane (upper and lower left and right layout), we will not use JavaFX.

5, provided the interface definition tool (Oracle Scene builder), although the comparison of soil, there is no shy to provide eclipse Plugin, but for us is basically enough, and we do not rely on Scene Builder to build the interface, Instead, the interface is built using a "pattern + assembly" approach based on the spring bean implementation.

6, support the use of CSS custom interface style, support HTML5.

7, provide a richer graphics components.

8, native printing support.

9, easy to implement Activiti flowchart definition, Excel-based BI tools and other high UI requirements of the components, which we would like to implement the basic components, on swing we do not dare to imagine, the coding workload will be very large.

10, JAVFX can be easily used in the development of Eclipse plugin, do not need additional configuration, etc., is conducive to the development of the Eclipse plugin system-based visual MDE development tools.

The use of the JavaFX + Spring bean assembly mechanism to facilitate the development of UI stereotypes is the main complex we choose for JavaFX.

Of course, the following inconvenience or problem must be endured:

1. The client must install the JRE.

2, JavaFX came too late, and not very mature. Everyone is saying that RIA is obsolete and must be used HTML5. To bear the risk of being referred to as "old-fashioned". However, we believe that in enterprise applications, stability, efficiency is the first goal to pursue.

3, the client will save some UI resources (jar package, configuration information, etc.) as the cache to improve the responsiveness of the UI-although we insist that this is the advantage of enterprise-class applications, but also can be attacked as "not pure B/S."

4, there may be security issues-although in enterprise applications, this is a large probability of pseudo-proposition.

Well, I can't see the above four.

J1001. Elementary Introduction to Java Native Desktop and web development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.