X

Java EE 7 Maven Application (TOTD #197)

Guest Author

Did you know that Java EE 7 APIs are now published in maven ?

The complete set of coordinates are href="https://wikis.oracle.com/display/GlassFish/Java+EE+7+Maven+Coordinates">described
here. So how do you build a simple Java EE 7 maven
application ?


  1. Generate the ususal Java EE 6 maven application as:



    mvn -DarchetypeGroupId=org.codehaus.mojo.archetypes
    -DarchetypeArtifactId=webapp-javaee6 -DarchetypeVersion=1.5
    -DarchetypeRepository=http://repo.maven.apache.org/maven2
    -DgroupId=org.glassfish -DartifactId=hello-javaee7
    -Dversion=1.0-SNAPSHOT -Dpackage=org.glassfish.hellojavaee7
    -Darchetype.interactive=false --batch-mode archetype:generate
  2. In the generated pom.xml, replace
    <dependencies>
    <dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>6.0</version>
    <scope>provided</scope>
    </dependency>
    </dependencies>

    with

    <repositories>
    <repository>
    <id>Java EE 7</id>
    <url>https://maven.java.net/content/groups/promoted/</url>
    </repository>
    </repositories>

    <dependencies>
    <dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>7.0-b72</version>
    </dependency>
    </dependencies>



    Notice, there is a new <version> of dependency for each href="http://download.java.net/glassfish/4.0/promoted/">GlassFish
    4 promoted build. This may be simplified in the coming
    builds.



    The <artifactId> can be changed to javaee-web-api
    if your application requires Java EE 7 Web Profile API only.


And now all Java EE 7 APIs so far integrated in GlassFish are
available in your application.

You can also include specific API JAR files explicitly in your
project directly. The latest APIs are available in the format:

  • Java EE 7 Full Platform: href="http://download.java.net/glassfish/4.0/promoted/javaee-api-7.0-b72.jar">http://download.java.net/glassfish/4.0/promoted/javaee-api-7.0-b72.jar
  • Java EE 7 Web Profile: href="http://download.java.net/glassfish/4.0/promoted/javaee-web-api-7.0-b72.jar">http://download.java.net/glassfish/4.0/promoted/javaee-web-api-7.0-b72.jar
  • Corresponding javadocs: href="http://download.java.net/glassfish/4.0/promoted/javaee-web-api-7.0-b72-javadoc.jar">http://download.java.net/glassfish/4.0/promoted/javaee-web-api-7.0-b72-javadoc.jar

In general, you can replace "b72" in the URL with the latest
promoted build number to get the latest artifacts. A simplified
URL for the latest set of these artifacts is in the works!



What next ? Maven archetype and href="http://wiki.netbeans.org/JavaEE7">support in NetBeans
coming soon!

Join the discussion

Comments ( 1 )
  • guest Friday, April 19, 2013

    Thank you very much.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.