4

I'm head over heels here !

I downloaded Java EE 7 SDK from this link http://www.oracle.com/technetwork/java/javaee/downloads/java-ee-sdk-7-downloads-1956236.html

During the installation. I was forced to install GlassFish. Unlik the Java SE installation, I had no option to chose a location for the Java EE libraries !

And now I'm left with GlassFish ! I know I'll have to deploy my application into an application server sooner or later, but I only need to include the Java EE libraries into my Eclipse java projects (Not even eclipse web project. I assemble my WAR using ant).

I believe I can go ahead and include Java EE libraries in my Run-Jetty-Run (Eclipse plugin to run jetty from eclipse) run configuration classpath, and fire my application up without any problem.

So my questions are:

  • Where are the Java EE SDK files ?!?! //Answered in the answer's comment
  • Why am I forced to use GlassFish ? //Answered below
  • Do I have any misconceptions here ? Am I correct to understand that I can include Java EE libraries my application's classpath, which is running within ANY servlet container and lunch my application without any problem ? //Answered below
  • I downloaded GlassFish server adapter. Configured the server but when I try to include GlassFish's runtime libraries, I can't find ANY configured server runtime library ! Check the attached picture. //Answered in the answer's comment
  • Is it still possible to assemble a WAR file using ant, without libraries, and run it on GlassFish through Eclipse ? //Answered below

I'm trying to do things with the least abstractions to learn more and understand what is really going on. That's why I prefer assembling my WAR file using ant from a regular Eclipse java project, and not a dynamic web project.

enter image description here

Muhammad Gelbana
  • 3,890
  • 3
  • 43
  • 81

1 Answers1

7

Where are the Java EE SDK files ?!?!

The default location on Windows is c:\glassfish4. Why GlassFish? See below.

Why am I forced to use GlassFish ?

GlassFish 4.0 is the "reference implementation" of Java EE 7.0. What does that mean? It means that it is the benchmark that compatible Java EE 7.0 servers are measured against. It forms the base-line for the Java EE test suites that other Java EE servers, like JBoss or TomEE, must pass.

Do I have any misconceptions here ? Am I correct to understand that I can include Java EE libraries my application's classpath, which is running within ANY servlet container and lunch my application without any problem ?

Yes, you have a misconception on how Java EE applications work. Your server provides the standard Java EE API JARs in its runtime classpath, so your application doesn't need to include them. The servlet container is part of the Java EE server. There is also an EJB container and an Application Client container. A web app deployed to the servlet container can use the standard Java EE services and APIs, like JAX-RS for RESTful web services, JPA for database access, etc.

Is it still possible to assemble a WAR file using ant, without libraries, and run it on GlassFish through Eclipse ?

That is how most Java EE development works, yes. People increasingly use Maven for this instead of Ant, though, as it's pretty easy to create a skeleton application using, e.g. the Code Haus Maven archetypes, and Maven will handle downloading and installing the correct artifacts to compile your app, and package it correctly to allow it to run on GlassFish, JBoss, TomEE, etc.

Ian Evans
  • 1,357
  • 10
  • 10
  • Thanks a lot for the elaboration. This cleared a lot of things :) But what about including Java EE and GlassFish libraries in my non-web projects (Projects to make libraries for my applicatoin; i.e. JARs) ? – Muhammad Gelbana Oct 10 '13 at 08:59
  • @MuhammadGelbana: It's very easy in Maven. You'd add a dependency to the javax.javaee-api version 7.0 artifact in your library project with the scope set to "provided". That way, the Java EE JARs are only used for compilation, and not packaged within the library project's output JAR. – Ian Evans Oct 10 '13 at 20:41
  • What about GlassFish API ? How can I refer to it from non-web java projects ? – Muhammad Gelbana Oct 11 '13 at 08:57
  • @MuhammadGelbana: The only reason you'd need to use GlassFish APIs in your application is if you are writing an application that needs to directly interface with GlassFish's services (monitoring, deployment, administration). So, why do you need the GlassFish-specific APIs? 99.99999% of users don't need these APIs. But if you do need the API, the artifact is org.glassfish.main.common.glassfish-api, version 4.0. – Ian Evans Oct 11 '13 at 16:57
  • I'm not an expert, I'm still learning but even if I'm among the 0.00001% who needs a specific feature, considering the whole world population, this could be a lot :D. However, I just found out that what I'm searching for, surprisingly, doesn't exist: stackoverflow.com/questions/17204096/… I appreciate your mentoring, I learned a lot :) – Muhammad Gelbana Oct 12 '13 at 01:26