How to run JDK 8 Java web application in JDK 11? - java

I have built a web application in JDK 8. Now I want to run that application in JDK 11. So is it possible to run a JDK 8 web application in JDK 11?
In my application, I have used servlets and JSP and database connectivity with MySQL.

So is it possible to run a JDK 8 web application in JDK 11?
For a normal application, the answer is simply yes.
For a web application, you don't run the app directly on a JDK or JRE. You actually run it in a web container that runs on the JDK or JRE. For example Tomcat, Jetty, Glassfish and so on. (For a webapp that uses just servlets and JDBC, you don't need a full J2EE container.)
However different webcontainers have different functionality and different ways of doing things that may be an impediment to a specific webapp.
So my advice is to find out what web containers are recommended for the webapp you are trying to run, and use one of those. Choose a version of the container that that is advertised as supporting Java 11.

Related

Does Java EE run on Java SE's JRE?

If I'm simply running a prebuilt Java EE (server) application, does it run on Java SE's JRE, the one found here?: http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html
You have asked two different questions:
Does Java EE run on Java SE's JRE?
Assuming that you mean an implementation of the Java EE specifications (e.g. Glassfish, JBoss, Glassfish, WebSphere, etc), then the answer is Yes.
All of these will run on a Java SE JRE. Indeed, you typically need to download a JRE separately from the Java EE implementation that you are using.
If I'm simply running a prebuilt Java EE (server) application, does it run on Java SE's JRE?
The answer to that is No. The web application needs a web container; e.g. Glassfish, JBoss, Glassfish, WebSphere, etc.
The webapp runs in a Java EE web container and the Java EE web container runs on a JRE.
Hopefully, the above will help you understand why the two questions you asked are different.
It should also be said that not all Java EE implementations are "equal". Some of them (for example Tomcat) only implement a subset of the Java EE specifications. However, a typical web application only requires a subset of Java EE; e.g. the Servlet, JSP and JSTL frameworks / implementations.
The question is, why would you try to run a JavaEE application without J2EE-Server.
If you want to do module tests, a subset of the functionality is sometimes enough to run limited parts of the application including h2-database access, message queuing in memory, asynchronous and timer-simulation, resource-injection ... together with a JUnit-Testrunner.
look for ejb-cdi-unit

Java web start JRE auto download for non oracle java

We have tricky situation with out Java Web start project where I need restrict it running on IBM JRE. Otherwise it will not connect back to my cloud application. There are various reason we are restricting to IBM JRE, one of them is cryptographic features.
Having said that, I have tried following things.
Added following tag in my jnlp
<j2se version="1.7.0_72+" href="http://9.182.74.244:8080/jreInstaller/download"/>
where /jreinstaller/download URI served by a servlet.
I have followed exactly how it was mentioned by unofficial web start project.
http://lopica.sourceforge.net/services/index.html
With Oracle Java I am getting below behavior. Instead calling my servlet which it is prompting below popup and running whatever available.
This application would like to use a version of Java (1.7.0_71+) that is not installed on your system. We recommend running the application with latest version of Java on your computer.
Am I missing something, how was unofficial web start services were working previously. Something changed with latest Java?
Oracle removed the JRE auto-download feature from Web Start in 2013: openjdk bug 8006701. Web Start now often (but not always) silently ignores the version specification.

Unable to create Java Web EE 7 project in Netbeans7.3.1

I am having a problem with Netbeans and when I tried to create a Java Web by following their instructions:
Choose File | New Project.
Under Categories, select Java Web.
Under Projects, select Web Application.
Click Next. Web Server-- Apache Tomcat 7.0.42
but Java EE version-is only EE6 and EE5. Why does it not Show EE7??
should i need to install any plugin?
I have the follwong installed:
JDK 1.7_upadte_42
Netbeans 7.3.1
Apache Tomcat 7.0.42
Tomcat is not a Java EE compliant application server to begin with, it is a servlet container1. It is clearly stated in the official site:
Apache Tomcat™ is an open source software implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies.
In order to use Java EE 7+ capabilities, you need to use a Java EE 7+ compliant server. Currently, AFAIK this is done by GlassFish 4 only. When you visit the official site, it is stated in the top: World's first Java EE 7 Application Server. Make sure you configure your project to use GlassFish 4 and then you may use Java EE 7 benefits for your applications.
Note that this is also covered in Netbeans 7.3.1 community news:
NetBeans IDE 7.3.1 is an update to NetBeans IDE 7.3 and includes the following highlights (emphasys mine):
Support for Java EE 7 development
Deployment to GlassFish 4 (not Tomcat)
Support for major Java EE 7 specifications: JSF 2.2, JPA 2.1, JAX-RS 2.0, WebSocket 1.0 and more
1 At least not until Tomcat 7. Looks like from Tomcat 8 it will support Java EE 7 profile (from the official site linked above):
The Apache Tomcat Project is proud to announce the next release candidate for Apache Tomcat 8 - 8.0.0-RC5 (alpha). Tomcat 8 is aligned with Java EE 7.
Short Answer: You need to use Tomcat 8+ for Java EE 7 web projects. Additionally (as mentioned), you may need to use a later version of NetBeans (7.4+) for full support.
Long Answer:
I'm a little late answering here, but I'm posting an answer for the record in case others see this question and to clear up misconceptions. Contrary to the prevailing belief, you can deploy Java EE apps to Tomcat.
There are two Java EE profiles relevant here: the "Full" profile (which includes the full Java EE stack) and the "Web" profile (a subset of the full profile which is designed to be implemented more easily by servlet containers). As mentioned, if you must use functionality only available in the full Java EE 7 profile you will need to deploy to an app server such as Glassfish 4+, [Jboss] Wildfly 8.1+, or JEUS 8.
However, Tomcat does comply with the Java EE Web profile, so you can deploy Java EE apps to it so long as you stick to just the functionality provided by the Web profile.* Often (if not usually) the web profile is all you need. The web project mentioned by the asker only uses stuff from the web profile. Tomcat 7 complies with the Java EE 6 Web profile and Tomcat 8 complies with the Java EE 7 Web profile, so the OP just needs to upgrade to Tomcat 8 if he wants to use EE 7.
* Oracle makes it easy to stick to one profile or another by distributing specific API jars for each profile ("javaee-api" for the full profile, "javaee-web-api" for the web profile, etc). That's the only dependency you need** to create Java EE apps, and you don't even have to (and shouldn't) bundle it in your WAR. In reality you may need to bundle (but not compile against) some libraries a la carte--or use the TomEE variant of Tomcat--to use all EE 7 web features.
** If you see gobbledygook about "endorsed dirs" and "endorsed APIs" in your build files, that's not a real dependency and is just to ensure that your code compiles against the correct class versions. For example, the standard (non-EE) Java 7 runtime already includes a version of JPA, but Java EE 7 includes a different version so the compiler needs to know which version to use. Don't take out that gobbledygook or you could (but probably won't) have runtime "class version incorrect" issues.
At the moment, Java EE 7 is only partially supported by Netbeans 7.3.1. They will support it in NB 8.0. Also, you need Tomcat 8 for Java EE 7, but their support is still partial too. Glassfish 4.0 is the way for now.
Here are some useful docs:
http://wiki.netbeans.org/JavaEE7
http://tomcat.apache.org/whichversion.html
http://docs.oracle.com/javaee/7/tutorial/doc/

Setup Java EE environment on Mac

I am new to Java EE. I want to setup Java EE environment to begin developing web applications. I read through articles on internet but they seems to be confusing. My question is that is there any one time installer for Java EE development environment setup? I mean like we have for PHP is that WAMP, XMPP, LAMP etc.
There is no single installer, but two will be enough - you will need an IDE - the most popular are Eclipse and NetBeans. And you will need a Java EE distribution which comes in the form of a Java EE compliant application server - the most popular ones are JBoss and Glassfish. With both IDE and server all you have to do is unpack them into folders of your choice.
The JavaEE distibution of NetBeans already includes GlassFish - even less to do for you ;)
As a prerequisite, you will need an installed JDK, a JRE won't do.
EDIT : In order to control the server and deploy from eclipse you will have to tell it where your application server is - there are according plugins for Glassfish and for JBoss.
I'm not sure about JBoss integration with NetBeans - never done it, but NB intagrates seamlessly with Glassfish.
Glassfish incldes a Derby (JavaDB) distribution, and JBoss includes a H2 DB distribution which both will be enough to start.
Using MySQL or other databases will require a bit of configuration, so if you're just starting - don't bother yet.
You might want to use Eclipse Juno Eclipse IDE for Java EE Developers,
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/junosr1

Problems with Java EE SDK

I need help with Java SDKs. I have installed Java SE SDK, and I also installed Java EE SDK. However, where are the JARs in the Java EE SDK? Isn't Java EE SDK a superset of Java SE SDK? Do I need both?
It doesn't seem that I successfully manages to add all libraries in IntelliJ.
Java EE is an abstract API. The application server (e.g. Glassfish, JBoss AS, Tomcat, etc) is the concrete implementation. The Java EE download link on oracle.com contains the concrete reference implementation of the Java EE API, which happens to be Glassfish.
In order to develop against the Java EE API, you just need to reference the application server's libraries in the compile time classpath (the build path as it is called in most IDEs). I'm not sure about IntelliJ, but in Eclipse all you need to do is to integrate the application server runtime in the IDE's server configuration and then associate the web project with exactly that server runtime in the project's properties.
You do not need to explicitly add it to the JDK library, even more, it would possibly make things worse in the future as in losing portability and possible major classpath troubles. See also this related (Eclipse-targeted) question: How do I import the javax.servlet API in my Eclipse project?
Java EE is a set of additional APIs/interfaces (and most usually, some implementations of these). These are APIs for web applications, EJBs etc. You can use the JDK to build for this, provided you have the additional APIs and the implementations. Most usually a Java EE application will run in an application or web container.
Ref. Link JDK = Java SE && JDK != Java EE?

Categories

Resources