简体   繁体   中英

Java EE and Desktop apps

I'm new to Java and have just started with some simple code.

I'm on a Linux machine, use the vim editor, use javac for compilation and 'java' for running programs.

Basically, for the time being, I am looking for building a desktop application using Java. I've heard about Java (EE/SE/ME) and my assumptions about them are:

  • "Core Java" is the "basic" Java language(with all the rules about variables, looping, methods classes etc).
  • Java SE is for Desktop Apps.
  • Java EE is for Web apps (using the HTTP protocol).
  • Java ME is for Mobile Apps.

However, I came to know that the difference among them is that "specification", from Difference between Java SE & Java EE

So my question is, can I create Desktop Apps using Java EE as well? Or are they only for creating Web Apps?

Java EE is a large collection of technologies that together forms a more or less coherent framework for building enterprise applications.

Now in the enterprise, server applications are used a lot and so many technologies focus on server functionality and/or multi-user. Serving web requests is but a part of this, there's also functionality for eg processing messages (JMS) and server remote method calls (remote EJBs).

A complete Java EE implementation like GlassFish or JBoss AS is not that often used for desktop applications (unless it's an application intended for personal desktop used, but that's browser based).

HOWEVER...

Nearly all of the technologies that make up Java EE can be independently used on top of Java SE and in combination with a graphical user interface.

For instance, there's an ORM framework in Java EE called JPA that makes it rather easy to store objects inside a database. A database, possibly an embedded one, can of course be used with desktop applications and this often makes sense. Eg an email application might store mails in such a database. JPA explicitly has a section in its spec about being useable in Java SE.

There's also a framework for dependency injection in Java EE called CDI. This among others makes it easy to isolate dependencies and get hold of them. It's a natural fit for MVC graphical applications to eg get hold of the model in a controller. Like JPA, CDI has explicit support for Java SE.

As the last example, Java EE by default requires JMS to be present, but in this case JMS is not even specifically a Java EE sub-spec. Java EE only requires a JMS provider to be present, so naturally Java SE can use JMS (there is even API in JMS that is only legal to be used in Java SE). Messaging in a way can be part of an architectural pattern that is just as useable in desktop applications as it's in server applications (the desktop toolkit Cocoa for example uses it intensively).

There are more Java EE technologies useable in desktop applications, but I hope the above has given you some idea.

Java EE is a collection of technologies, including web apps.

Most of it isn't, though--things like JMS and JPA are part of Java EE, and are application-type-neutral.

Okay guys, I was new to Java and now I have become a bit "old". So I could figure it out.

This is it :

The ONE AND ONLY ONE required thing to Java development is a Java compiler which we get if we install a JDK and the thing we need to run a Java utility is a JVM. So these are the only things we require for ANY sort of Java Development(No matter Desktop, Web or mobile).

Then what is Java SE, Java EE and Java ME ?

Those are the above mentioned two things(Java compiler + JVM) plus a set of libraries(SE for Desktop, EE for Web, ME for mobile). So if any of us have enough time and have got a Java Compiler + JVM, we can build our own libraries for all those functionalities.

But following the concept "Don't reinvent the wheel" and because we'll be better off using a library/tool that has been running smoothly for years we all use the tools/libraries provided by SE, EE and ME.

So the answer is, I can develop any sort of applications with just a Java compiler(/usr/bin/javac on a Linux machine). The only thing is that there will be a lot of 'reinvention of the wheel'. And all java apps run on the same JVM(no matter what sort), in case of linux(/usr/bin/java).

Java EE is Java SE + enterprise technologies. So yes, you can build desktop app using java EE.

Java EE is just a set of specifications. Most of its implementation need something more than Java Runtime Environment used for JSE.

Different parts of Java need different kinds of containers.

在此输入图像描述

Parts of Java EE 6 You can run on JRE:

Java EE 6的一部分您可以在JRE上运行

Note about JSR 299 from the Weld website :

But the specification does not limit the use of CDI to the Java EE environment. In the Java SE environment, the services might be provided by a standalone CDI implementation like Weld (see Section 18.4.1, “CDI SE Module”), or even by a container that also implements the subset of EJB defined for embedded usage by the EJB 3.1 specification.

GlassFish can also run Java SE app in Embedded Enterprise Bean Container within the same JVM as Java EE app, so You can for example access Java EE's EJB using local interfaces.

Souroce of the images

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM