I am completely new to java and now I need your help.
The different between JavaSE and JavaEE is clear to me.
But why do I need for JavaEE coding an application server.
Or lets say, I try to code a websocket server in java and i did it with this tutorial:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/HomeWebsocket/WebsocketHome.html
But do I need an application server like in this case glassfish???
Java EE is the specification, and Glassfish is Oracle's implementation of Java EE. Glassfish can run the byte code that is generated from compiling your source code. You must have some implementation of Java EE in order to actually run the code that you write using Java EE. An alternative server for WebSocket capabilities is Tomcat from Apache.
It's similar to how a JRE is an implementation of Java SE. You must have a JRE in order to run the code that you write using the Java SE specification.
Related
I'm trying to understand the differences between Java SE and EE. There is a lot of information out there but from my current limited understanding, it seems like Java EE is just Java SE with some stuff added on top of it. Why can't I just use Java SE and import API or packages when I need them? For example if I need to be able to connect to a database I can import the JDBC API, is doing that any different that using JDBC in Java EE?
... it seems like JAVA EE is just JAVA SE with some stuff added on top of it.
That is incorrect.
In reality, Java EE is a specification, and a set of libraries that provide API interfaces to program against. What Java EE per se does NOT provide is the implementations of those interfaces.
A Java EE implementation is embodied in code that has been written by Java EE vendor. That implementation may or may not be a product that you have to pay for.
The other thing is that Java SE is not a part of Java EE. Not in any sense. Java EE APIs (and implementations) depend on a JVM and a Java SE class library, but they are separate things, and they are typically distributed separately.
Why can't I just use JAVA SE and import API or packages when I need them?
Assuming that you have downloaded the Java EE API JAR files (or your build tool has done it for you), you can compile your code against the Java EE APIs.
But you can't >>run<< your code on a plain Java SE platform because neither Java SE or the Java EE API JARs contain the classes that implements the Java EE APIs; i.e. the servlet framework, etcetera.
If you try a Java EE app without the vendor-provided code, it won't work. (If you don't believe me / us, try it for yourself.)
For example if I need to be able to connect to a database I can import the JDBC api, is doing that any different that using JDBC in JAVA EE?
JDBC used to be a Java EE API, but now it is a Java SE API. (Check the Java SE API documentation!)
But here's the thing. If you want to connect to a database using JDBC, your application needs to use database specific JDBC drivers ... which you get from the database vendor. (Just like you get a Java EE implementation from a Java EE vendor!)
Why can't I just import libraries into Java SE instead of paying for Java EE?
Most of this has been addressed above. But you also mentioned "pay for".
The reason you need to pay is because Java EE implementations are typically proprietary products. A company invested a lot of money in developing their codebase, and they want to make a return on that investment.
And indeed, from Java 9 onwards, Oracle Java SE is not free either ... for most use-cases.
In either case, there are three alternatives if you really don't want to pay:
Find a free (e.g. open source) implementation. They exist for Java SE and Java EE.
Develop your own implementation of the relevant specs. (That will be more expensive in terms of time than paying a vendor.)
Use the product without paying the required license fee, and hope that you don't get sued for a lot of money copyright violation, etcetera.
Isn't Java platform independent?
The Java programming language is platform independent.
The Java SE APIs are platform independent (more or less).
A Java SE implementation is NOT platform independent. If you download Java SE for Windows and try to run it on Linux, it won't work. (Never has, never will).
The "write once, run everywhere" mantra assumes that you have installed a Java SE implementation of the appropriate version on the platform. It doesn't imply that such an implementation exists, or that it will be available for free, or that it will be installed everywhere.
What "write once, run everywhere" mantra is actually saying is that you don't have to modify your Java application in order to make it run on another Java platform. (And note that there a number of caveats on the nature of the application for WORE. For example, it mustn't depend on native libraries or external applications that may or may not be present.)
Can't I import the Java EE library, get java.servlet.Servlet, program with it, the host my application server on any computer that has a connection to the internet and a static Ip address?
In two words: You can't.
No matter how many times or how many different ways you ask.
The Java EE libraries you mean only define interfaces. you don't need to pay for them. But you need an implementation of this interfaces. For instance, you can import Java EE library and you will get java.servlet.Servlet. But will have no implementation of this class.
To run a Java EE application you need a platform that, simple said, implements all these interfaces. Such platforms are so called so called Java EE runtimes or application servers like WildFly or WebSphere.
Is it possible to run resteasy or any jax-rs implementation in java se. Without the use of servlets container or javaee application container
Since Java SE 6, there's a builtin HTTP server in Sun Oracle JRE. The com.sun.net.httpserver package summary outlines the involved classes and contains examples. In theory that one could be used to run resteasy i guess.
Note: this is only available in the JVM as provided by Oracle!
The following answer simple-http-server-in-java-using-only-java-se-api provides more details regarding providing a servlet with plain java se.
I want to remove the Java EE dependency from my codebase so that my program is much more portable and easier for "average joe" to use. I really would like to not use the mail.jar since that relies on a Java EE container (JBoss, Tomcat, etc). I'd also like to not rely on something that simply wraps mail.jar (apache commons-email) since that still depends on Java EE.
I have seen some stuff online that hints at using sockets in Java SE, however the examples I found commentors posted that they did not work or were broken.
Since Java EE is built on Java SE, surely Java SE can send email without Java EE?
How can I accomplish this? (Want to send through Gmail for now, but future support of other SMTP services such as Exchange, Zimbra would be great).
The JavaMail API is available as an optional package for use with Java SE platform and is also included in the Java EE platform.
Reference
We often say that the particular application server is a Java EE compliant server. But I am still not completely aware of what it means exactly. Need more information on this.
It means that it passes the Java EE Technology Compatibility Kit.
Sun (now Oracle) created the specification for Java EE (previously called J2EE) along with a large test suite checking that the application server behaves as the specification requires. This is a non-trivial test to pass, but means that if you write your application according to the Java EE specification it will be able to be deployed and executed on any Java EE application server (of that level).
Note that the configuration is outside the specification. This means that the configuration of the application server to provide the things your application needs, is non-standard and it may be a quite substantial effort for you to add support for a new application server.
What Thorbjørn Ravn Andersen said is perfect. Also, the Java EE 6 Technologies page lists the technologies included in Java EE 6 specification. You can consider any Application Server fully implementing these to be Java EE-Compliant.
Also the Compatible Implementations page lists the list of AS compatible to each Java EE version.
in a tutorial they asked me to install the application server which could be downloaded from their site.
what do they mean with application server?
the link they provided: http://java.sun.com/javaee/downloads/index.jsp
i mean come on sun, all these names. jdk then j2ee..and when i wanna download j2se it says jdk6. r they insane? a lot of people are wondering what is what...they just dont know how to name things.
however, back to the question. so with application they mean java ee server?
i've got a mac and people say java is already installed. what is installed exactly? the j2ee or j2se? do i have do download j2ee? Java is just killing me...
EDIT: read something about that the application server is a name for ee server. and there are many ee servers like tomcat, jetty and glassfish. and i know these sometimes are called servlet containers.
so that makes application server = ee server = servlet container?
and jdk = j2se? so j2ee != jdk?
Sun's Application Server has been superseded by the community app server, GlassFish.
The JavaEE download page only has two JavaEE6 download links and both contain versions GlassFish v3. Chances are you only need the web profile, but download the full version if you aren't sure.
Note that GlassFish is just the reference Application Server. You also have other Application servers, such as Apache Geronimo and Oracle Weblogic... as well as ones that are just servlet containers, like Apache Tomcat and Jetty. These types should correspond to GlassFish's normal and web profiles respectively.
These other servers only require a JRE to run applications, or the JDK to develop for them.
Side Note: GlassFish v3 is the only JavaEE 6-compliant server... JavaEE 6 is brand new. The others should be JavaEE 5 compliant.
Also, JavaEE is the new name for J2EE, as sun tries to move away from the Java 2 name.
What do they mean with application server? The link they provided: http://java.sun.com/javaee/downloads/index.jsp
An application server is a component-based middleware used in server centric N-tier architecture. It manages the life-cycle of components deployed on it, it provides services for state maintenance, data access (with pooling of resources), security, clustering and fail-over.
AFAIK, one of the first application server (as just defined above) was ATG Dynamo. Other proprietary application servers include BroadVision, ColdFusion, etc. But none of them really survived to the advent of Java application servers (understand application servers based on the standards defined by Java EE and the Java language).
I mean come on sun, all these names. (...)
Wikipedia does a pretty good job at defining what Java SE is:
Java Platform, Standard Edition or Java SE is a widely used platform for programming in the Java language. It is the Java Platform used to deploy portable applications for general use. In practical terms, Java SE consists of a virtual machine, which must be used to run Java programs, together with a set of libraries (or "packages") needed to allow the use of file systems, networks, graphical interfaces, and so on, from within those programs.
The JRE (Java Runtime Environment) provides the virtual machine and the set of libraries i.e. everything you need to run Java software. The JDK (Java Development Kit) provides a JRE plus a compiler (javac) and some other tools i.e. everything you need to run and develop Java software.
Java EE is a specification (more precisely, a set of specifications) built on top of the libraries provided by Java SE and is more server-side oriented. Implementations of this specification are provided by Java application servers: GlassFish is Sun's implementation, JBoss is RedHat's implementation, WebLogic is BEA Oracle's implementation, WebSphere is IBM's implementation, etc.
Regarding the versions and nomenclature, yes, Sun is crazy. It was an horrible mistake to introduce this "Java 2 Platform, Standard Edition" naming when the version 1.2 came out. I can imagine how confusing this is. But, again, Wikipedia does a great job at clarifying this in the section Nomenclature, standards and specifications:
Java SE was known as Java 2 Platform, Standard Edition or J2SE from version 1.2 until version 1.5. The "SE" is used to distinguish the base platform from Java EE and Java ME. The "2" was originally intended to emphasize the major changes introduced in version 1.2, but was removed in version 1.6. The naming convention has been changed several times over the Java version history. (...)
This should make things more clear.
(...) however, back to the question. so with application server they mean java ee server?
Yes, this is what they mean or, more precisely, they mean Sun GlassFish Enterprise Server (previously named Sun Java System Application Server). Source: http://developers.sun.com/appserver/.
I've got a mac and people say java is already installed. what is installed exactly? the j2ee or j2se? do i have do download j2ee? Java is just killing me...
A JRE or a JDK (if javac available, it's a JDK), so only the Java SE part. And actually, if you are still following me, you don't download Java EE, you download something providing an implementation of it (i.e. an application server).
(...) so that makes application server = ee server = servlet container?
No. To simplify, a Java EE server = Servlet container + EJB Container. Some server are only Servlet container (like Tomcat, Jetty), they don't provide the EJB container part and thus don't fully implement the Java EE specification and can't be considered as full Java EE servers.
and jdk = j2se? so j2ee != jdk?
I hope I covered this with my answer.
In order to run you Java EE applications you need an application server.
The link you provided is to download GlassFish that is one application server.
There are others application servers like Apache Tomcat, Jboss.
JDK stands for Java Development Kit
You need this to develop Java applications.
JRE stands for Java Runtime Environment
You need this to run Java applications.
GlassFish with the Java EE SDK (provided on the link you gave) is what you need. Java EE server = application server.
What is installed on your Mac by default is probably only a JRE (runtime environment) and not a JDK (development kit). Which means, you can run Java apps but not develop. By downloading GlassFish with the Java EE SDK, you'll get the full-blown SDK you need and a server to deploy on.
Hope that helps.