Running Resteasy in java se - java

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.

Related

Java Spring requires some EE features in Tomcat. Is Spring a Jakarta EE framework?

I spent the last few days trying to wrap my head around the Java ecosystem, looking at the components (JVM, JRE, JDK, SE, EE, etc.), licensing and others.
As far as I understand, Jakarta EE (formerly Java EE, J2EE) is an API on top of Java SE with lots of enterprise-grade features and lots of (mostly deprecated) web technologies. Spring has similar goals but a different approach and runs on "standard" Java SE.
But then what about Tomcat? Tomcat is defined as an implementation of Jakarta EE features. I understand that TomEE is a "superset" of Tomcat with more Jakarta EE features.
Nevertheless, Spring (needs / requires) Tomcat as a runtime. Does that mean that Spring uses Jakarta EE features? Could you please clarify these differences?
Tomcat 10 offers JakartaEE, but no JEE.
Versions lower than 10 implement JEE but no JakartaEE. Here's the overview
To my knowledge, spring works on JEE, but not JakartaEE (at the time of writing this answer). So if you want to use tomcat with spring, pick version 9 (as of today), or another JEE container.
Spring does not implement most of the JakartaEE/JavaEE specification. One of the Spring project that implements a JSR defined in JavaEE that I can think of is spring-batch (see this).
Instead, Spring mainly provides support to integrate with a carefully selected individual specifications from JavaEE to allow developers to work with the implementation of these specifications using the Spring programming model (See this for more detail.)
Tomcat is the implementation of the Servlet API which is one of the specification that is included in JakartaEE/JavaEE. To me , the most useful and modern support provided by Spring for it is spring-boot allows to package the application using an embeddable Tomcat such that we can simply deploy and run the application as a JAR without install a Tomcat server separately and deploy the WAR to it.

Do I need an applicationserver for Java WebSocketServer

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.

Use JavaMail (mail.jar) without dependency on Java EE

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

What does Java EE compliant means?

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.

sun's application server?

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.

Categories