Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java EE and Glassfish

I just installed Java EE SDK, which was bundled with Glassfish. The website wasn't clear, but it seemed these had to be downloaded together. I'm just trying to figure out where EE is actually installed in my system. All I see is C:\glassfishv3 and the directories underneath it.

Isn't Glassfish just a web server that is independent of EE? I just want to write Servlets using classes found in EE. Kind of annoyed that Oracle is pushing their server with the API extension.

So my questions are:

  1. Can I remove Glassfish from my system and still build programs with EE?

  2. Where is EE installed?

Thanks a lot for your help.

like image 420
dvanaria Avatar asked May 18 '11 05:05

dvanaria


2 Answers

Glassfish is a EE-compliant server. This means, it can host non-EE applications as well, but also brings the necessary libraries with it to host EE applications.

EE is a standard for container management of objects, database integration and several other concerns. There are a number of servers out there, implementing different versions of the EE standard. Glassfish is the "official" implementation from Sun/Oracle. Others include IBM Websphere, JBoss, Oracle Weblogic

  1. You can program enterprise java without a Glassfish server. You will need a different implementation though, like JBoss.

  2. The actual "EE installation" consists of a bunch of .jars in the /libs folder (I'm not sure about the exact name as I don't have Glassfish installed). The most important one is the javaee.jar, [note: found in C:\glassfishv3\glassfish\lib]

like image 78
kostja Avatar answered Nov 15 '22 16:11

kostja


JAVA EE is a standard. There are multiple implementations of this standard. GlassFish server is the reference implementation by Oracle. As Kostja already mentioned the implementation contains a bunch of jars. Depending on which EE technology you are going to use, you need different set of jars.

If you just want to write servelets, apache-tomcat is enough for you, GlassFish will also work, but GlassFish is a complete application server where Tomcat is the servlet container.

Just create a maven web project and deploy under tomcat. You don't need to install anything else. Maven will fetch necessary EE jars for you.

Here is a sample pom.xml for a simple web application.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.sonatype.mavenbook.ch05</groupId>
  <artifactId>simple-webapp</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>simple-webapp Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.6</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.4</version>
      <scope>provided</scope> 
    </dependency>
    <dependency>
       <groupId>javax.servlet.jsp</groupId>
       <artifactId>jsp-api</artifactId>
       <version>2.0</version>
       <scope>provided</scope>
    </dependency>
  </dependencies>
      <build>
    <finalName>simple-webapp</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
  </build>
</project>
like image 42
rangalo Avatar answered Nov 15 '22 14:11

rangalo