Moving to Java 6 EE from Java 6 SE - java

I have Java 6 SE, Tomcat 6, Eclipse Helios for J2EE, Chrome Browser Dev for JS up and working. Sometimes I need the source and doc for java libraries I believe are in the EE kit. What is the best way to get the source and doc and be able to use it in my dev environment without messing it up?
Is this as simple as running the Java 6 EE install package on Vista 64bit?
If I have the download, is there a way to extract the files and manually place them?

This question is confusing. You mention Java EE 6 in the title and then Tomcat 6 in the body but Tomcat 6 doesn't implement any of the standards from Java EE 6. Sure, you can run some parts of the Java EE 6 specification on it like JSF 2.0, CDI, JPA 2.0. But still, Tomcat 6 only implements Servlet 2.5 and JSP 2.1 and has thus little to do with Java EE 6 (and Tomcat 7 also only implements Servlet 3.0, not the Java EE 6 Web profile, and they don't plan to implement it).
I'm not suggesting to move away from Tomcat if it suits your needs, I'm just clarifying that neither Tomcat 7 nor Tomcat 6 do provide a Java EE 6 (Web Profile) implementation.
If Tomcat 6 appears to be what you're looking for, you can download a "Source Code" distribution from their website (go to the bottom of the page) and attach the sources in Eclipse, as suggested by BalusC.
If you really want to "move to Java EE 6", you'll need a Java EE 6 server (either supporting the full Java EE 6 specification or only the Web Profile) like GlassFish 3.0.1, GlassFish 3.0.1 Web Profile, JBoss 6.0, Resin 4.0 (Web Profile implementation). They all provide sources of their implementation. If you go this way, let me know and I'll add more details if necessary.

The Java EE is an abstract API. The application server is the concrete implementation. The Java EE 6 kit provided by Sun Oracle contains basically the Glassfish server. But you already have Tomcat as server. Just get its source from http://tomcat.apache.org. You need to ensure that the source version matches the Tomcat version. If you're using an older version than currently latest 6.0.29, then you need to get it from the archive. It's in the /src folder of the version folder. You can download it as zip, put it somewhere on your disk (I myself put it directly in Tomcat installation folder). Finally have Eclipse point to the zip file whenever you want to view the source for the first time (e.g. HttpServlet and so on).
Noted should be that Tomcat 6 only implements Servlet 2.5 / JSP 2.1 which are part of Java EE 5, not 6. But it may be more than sufficient for your needs. For the remnant of the detail see #Pascal's answer.

Related

Getting ClassNotFoundException for HttpServlet in Tomcat in INtellij [duplicate]

I have a Java application which shows Apache Tomcat Embed as 9.0.35 version. I need to update this to 10.0.4. I'm very new to Java and have very minimal knowledge on it. This upgrade is needed to resolve some vulnerabilities with in the application.
How can I do this from IntelliJ IDE?
Tomcat 9 & 10 are equivalent products
Apache Tomcat 9 and 10 are equivalent products. The only difference is support for changes for the package names in the Jakarta Servlet and related technologies from javax.* to jakarta.*.
This package name change is for legal reasons involved in the transfer of responsibility for Jakarta EE (formerly Java EE) technologies from Oracle Corp to the Eclipse Foundation.
For more info, read Understanding Jakarta EE 9.
To quote the documentation:
Users of Tomcat 10 onwards should be aware that, as a result of the move from Java EE to Jakarta EE as part of the transfer of Java EE to the Eclipse Foundation, the primary package for all implemented APIs has changed from javax.* to jakarta.*. This will almost certainly require code changes to enable applications to migrate from Tomcat 9 and earlier to Tomcat 10 and later. A migration tool is under development to aid this process.
Move to the latest 9 rather than 10
Tomcat 9 and 10 track the same development changes. If your goal is simply to gain some security fixes, as far as I know you'll get the same fixes in both 9 and 10. Do not take my word for this, just study the Tomcat Release Notes.
So for the fastest easiest migration path, just upgrade to the latest 9 instead of 10. The current latest version of 9 is 9.0.44.
Stick with Tomcat 10
Alternatively, if you want to proceed with using Tomcat 10, change the import statements across your code base to use jakarta.* in place of javax.*.
IDEs such as IntelliJ have added features to assist in this migration chore.
And you’ll need to update any third-party libraries using javax.* to new versions using jakarta.*.

GlassFish vs tomcat [duplicate]

This question already has answers here:
What is the difference between Tomcat, JBoss and Glassfish?
(8 answers)
Closed 8 years ago.
I would like to start using JEE6 in the next project that I have to work on at my job, but there is also a limitation (sort of): Tomcat 5.5
My question is, what improvements would bring GlassFish to the table (security/speed) vs the existing Tomcat(5.5) or an upgrade to the newer version 7?
Q: My question is, what improvements would bring GlassFish to the table
(security/speed) vs the existing Tomcat(5.5) or an upgrade to the
newer version 7?
Tomcat 7 compared to Tomcat 5.5 supports newer version of JSR specifications. Therefore, if you wish to use for example Servlet 3.0 or Websockets, you don't have other choice but to upgrade the Tomcat version. See this link for the full list of Tomcat versions and supported specifications.
However, Tomcat is not Java EE container, but only a servlet container. In other words, if you plan to use full Java EE (which includes security and many other things), you have to switch from Tomcat to some of full Java EE application servers. Glassfish is one of them, others are TomEE (similar to Tomcat, so perhaps a good starting point), WildFly, IBM Websphere, Oracle Weblogic etc. Unfortunately, Oracle recently decided to abandon commercial support for Glassfish, so maybe it would be wise choice to go with some other application server if you would like to use it commercially.
One way or another, move from Tomcat 5.5 because it is a quite old version of Tomcat.
See also:
Java EE containers vs Web containers
Oracle abandons commercial support for Glassfish JEE Server

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/

Install Java EE 6 on OS X Lion

The Java Preferences application on my OS X Lion workstation indicates that I have Java SE 6 v1.6.0_29-b11-402 installed (both 32- and 64-bit versions). Unfortunately, I need additional features at are only available in the Enterprise Edition.
A comment by 'Jesper' in 'How install a specific jdk on Mac OS X?' suggests that I need to use the Java supplied by Apple, rather than the one from Oracle/Sun. Unfortunately, it doesn't seem that Apple offers an Enterprise Edition of Java 6.
This leads me to ask a number of questions:
Did I miss something? Does Apple offer an EE of Java 6?
If 1 is true, how do I get it? Can it be installed 'side by side' with the Java SE 6?
If 1 is false, can a Oracle/Sun version be used? Is there a recommended installation location? I'm guess that the /System/Library/Frameworks/JavaVM.framework/Versions/ folder is not recommended.
The Oracle/Sun version seems to include a lot of extras (e.g. Glassfish) that I would prefer not to install. Can I install the core SDK w/o the extras? Will Tomcat 7 work as an alternative to Glassfish?
** edit **
This question is a result of another question that I posted: RESTful web service: java.lang.NullPointerException service.AbstractFacade.findAll. It seems that this particular error is a result of a missing annotation (#Stateless). This annotation is 'contained' in the javax.ejb.* namespace, which is contained in a .JAR file that is not on my workstation.
This led me to conclude that I needed the 'Enterprise Edition' of Java 6 (which would have the missing .JAR file and other dependent files). I suppose if there was a way to determine which .JAR file is missing (Netbeans 7 doesn't seem to help with this) I probably could just add it to the project and skip the EE hassles.
There is no such thing as a special runtime called Enterprise Edition of Java for any platform.
There is Java SE and there are simply some interfaces that an Enterprise Edition container implements.
Sun confused the market with the naming convention years ago when they came up with J2EE. It never was a separate version of Java, just some tacked on APIs that if a server implemented them and passed some certification, could call themselves a J2EE container.
They further confused the market when they started calling it Java EE 6.
If you are developing against these APIs all you need is the .jar files that contain these interface declarations. You can download these API .jar files which used to be called J2EE. But they are pretty useless by themselves.
But I doubt that you are wanting to write a Java EE server, you want to use one. If you want to use a server then you need to download a Java EE compliant server and use the .jar files it provides.
Every IDE worth using includes these in some form, usually by defining a Server that you will be deploying against. Tomcat isn't a fully EE container. It is a Servlet container, which is a subset of the full EE specifications.
As of OSX Lion, Apple doesn't supply a JDK anymore, it is only the Oracle one, which you apparently already successfully acquired.
Java EE 6 is a spec, with some accompany API represented as interfaces. Java EE 6 in and of itself is not an implementation of those APIs. If you wish to use the Java EE 6 APIs you will need to avail your self of a compatible Java EE Application Server. Glassfish is the reference implementation of Java EE 6, however there are other servers as well that are compliant. JBoss is another popular option.
These install easily on Mac OS X.
There is a Java EE download. http://www.oracle.com/technetwork/java/javaee/downloads/index.html On its own though, its not particularly useful unless you're trying to develop an application that is intended to run in multiple containers.
What you will typically want to do is to download a container and develop with that. e.g. Glassfish (available at same link above). This task can be made easier with support from an IDE such as Netbeans. You can download a version of Netbeans that already includes Glassfish and the Java EE APIs and just start working. Other IDE/container combinations are possible, usually there is some sort of plugin available.
The Java 6 JDK/JRE for OSX is still from Apple. They transitioned most of the code to Oracle however, and the OSX version of JDK 7 is close to release status, and it may be mature enough for your purposes. My best guess is that it is.

how many versions of java are there?

I am little confused about Java frameworks (I am coming from .NET). Do you need different server setups to run Java, J2EE and JSP? Does Java make a distinction in frameworks for enterprise and non-enterprise deployments? Beans? Struts?
Can someone make sense of this for me?
.NET has:
Windows development (Winforms, WPF)
web:
i) webforms
ii) mvc
These are the most commonly used terms that correspond to your "Java versions":
JRE: Java runtime environment, what's needed to run Java programs
JDK: Java development kit, a JRE plus compiler and some additional tools
Jave SE: Standard Edition, the API library that comes with every JRE and JDK for desktop use
Jave EE: Enterprise Edition, additional APIs that extend the J2SE for business use, meaning mainly server applications - this includes JSPs
Jave ME: Mobile Edition, a set of APIs (mainly a subset of J2SE) for mobile devices like phones
(The latter three are often also written as J2SE, J2EE and J2ME meaning "Java 2 ___ Edition" - Sun's naming and versioning convention are rather confusing)
Note that all of these are basically specifications, and there are implementations from different vendors. For example, you can get a J2SE 6 JDK not only from Sun, but also from IBM and Oracle.
There's a few different ways of looking at this.
Firstly, the only current version of Java is Java 6 currently at Update 17 or so. Java 5 and earlier have all been end-of-lifed. What's a little confusing is that starting at version 1.2 Java adopted the name "Java 2" (and was referred to as J2SE or "Java 2 Standard Edition") so it was Java 2 version 1.2. After Java 2 version 1.4 (or more simply Java 1.4). Version 1.5 became Java 5 or J5SE although J2SE is still pretty common.
The other version of Java that's relevant is Java Enterprise Edition ("Java EE"), formerly J2EE ("Java 2 Enterprise Edition") with version 6 being imminent. Java EE specifies a set of standards for server apps. The most important part is the servlets specification, which is the basis for 99.9% of Java Web frameworks. It has versions and is currently at either version 2.5 or 2.6 (I forget). Apache Tomcat is the reference implementation of the servlets specification.
Another part is EJB ("Enterprise Java Beans") currently at EJB3/3.1. It's a component architecture and really heavyweight. It's not used anywhere near as often as the base servlets specification.
Whereas Tomcat is a Web container, full Java EE supports is provided by what's called an application server. Examples include Glassfish, JBoss, Weblogic and Websphere.
Java classes are often packaged as JARs ("Java ARchives"), which is simply a zipped file with a specified directory structure.
Web applications are packaged as wars ("Web ARchive"), which is just a jar with a different extension. WARs may contain libraries in JAR form.
Full Java EE apps are packaged into EARs ("Enterprise ARchives"), which again is just a different file extension and it may contain war and other files.
Now to complicate this there are about a bazillion Java Web frameworks such as Struts, Spring MVC, Tapestry, Wicket and many, many others.
Also, it's fairly common for Java Web and enterprise apps to use the Spring framework. Spring is (imho) a must-have for Java serverside development as it simplifies a lot of vendor and library differences and makes your application far more pluggable.
Confused yet?
There are several versions of the JDK (1.4, 5, 6), much like there are several versions of .NET (1.1, 2.0, 3.0, 3.5). J2SE and J2EE are really just different packagings of the same version. J2EE includes some extra namespaces that aren't in J2SE.
From wikipedia:
Java Platform, Enterprise Edition or Java EE is a widely used platform for server programming in the Java programming language. The Java platform (Enterprise Edition) differs from the Java Standard Edition Platform (Java SE) in that it adds libraries which provide functionality to deploy fault-tolerant, distributed, multi-tier Java software, based largely on modular components running on an application server.
If you are going to implement a web application with Java, you can use Apache or Tomcat as a webserver.
To develop in Java, I suggest downloading NetBeans from here:
http://netbeans.org/downloads/
I prefer NetBeans than Eclipse because it is more similar to .NET's IDE, which basically means, it is more helpful.
With NetBeans, you can program every type of Java application, from a client java application, to a servlet, applet, etc...
There are 3 main Java platforms:
Java SE (standard edition)
Java ME (mobile edition)
Java EE (enterprise edition)
They all have the Java programming language in common, but differ in terms of APIs and libraries included in them.
From your question I'm guessing you're looking at Java EE?
Although it is possible to code an enterprise application in Java SE, Java EE is the natural choice because it takes care of many things you would face and allows you to focus on the interesting and useful parts of your application.
Java doesn't really distinguish from enterprise and nono-enterprise, in fact, you can use the APIs from Java SE in Java EE, and it's possible to use Java EE APIs in Java SE programs.
So what's the difference then?
Essentially, they are all platforms, execution environments. Java EE is more suited to developing big projects than Java SE, and as such includes various servers and things to help you code those big applications.
Beans, Servlets, Apache Tomcat server, Glassfish server all fall under the Java EE platform.
First you have the Java SE which contains the standard Java API. You can download it as JRE (only runtime) or as JDK (includes developer tools like java compiler).
Then you have the Java EE which contains the enterprise Java API. Java EE is in fact an abstract API (exist of almost only interfaces, abstract classes and API contracts). You need a concrete implementation to get a running Java EE platform. In case of JSP/Servlet you basically need a servlet container. Commonly used ones are Apache Tomcat and Sun Glassfish (which is bundled in Sun Java EE download).
You do NOT need to download the Java EE from Sun when you need Apache Tomcat. Just the Java SE is enough. The Sun Java EE download contains basically the Glassfish server and is also available as a bundle with Netbeans IDE (which I personally don't recommend for web development; Eclipse or IntelliJ are better choices for web development).
Let assume you would like to use Eclipse and Tomcat, then to get started with web development you basically need the following:
Java SE JDK 1.6
Apache Tomcat 6.0 (core, binary distributon)
Eclipse IDE for Java EE developers
jstl-1.2.jar (standard JSP taglib, use it instead of scriptlets!)
To kickoff with all:
Install Java SE.
Extract Tomcat zip and put it in desired location.
Extract Eclipse zip and run eclipse.exe.
In Eclipse's Servers view, add new Tomcat server and point to the Tomcat location.
In project explorer, create new Dynamic Web Project and pick the Tomcat from the list.
In the created project, drop the JSTL JAR in /WEB-INF/lib.
That should be it. You can create JSPs in /WebContent folder and create classes (servlet, filter, bean, domain, utility, etc) in src folder.
As to Struts, it has nothing to do with Sun. It's a component based MVC framework of Apache which is roughly said the competitor of Sun JSF. You can download it separately, put the libraries in WEB-INF/lib and use it in the project.
There is one JDK (only JDK 6 is supported today) and the Java Runtime Environment (JRE 6).
Typically you need only the JRE, but some frameworks need the tools.jar (i.e. javac) to run.
Even server and client modes can be detected and the Java EE libs come with the application server (or web server) you use.
Actually java has many other editions but normally we did not use that in applications ,
list given below :
JavaSE
JavaME
JavaEE
JavaFX
JavaCard
JavaDB
JavaTV
JavaEmbeded
and we can have 4 types of files in java :
Jar (Java archive)
War (Wep applications archive)
Ear (Enterprise application archive)
Rar (Resource adapter archive)
sorry for speling mistakes ,,,,

Categories

Resources