Sun Java Solaris Communities My SDN Account Join SDN
 

Java EE Code Samples & Apps

Centralized intelligence.
Essential docs, code, and articles instruct and inspire.  
» GlassFish Samples
» Contribute New Samples

Java EE Code Samples & Apps

Java EE 5 | J2EE 1.4 | Other Samples

Java EE 6 Sample Applications

Click the sample application to learn about the sample and the procedure to build and run. Some of the sample applications require you to configure resources (such as a database, JDBC, Connector, JMS or JavaMail). If so, the individual sample documentation will explain the necessary steps.


Sample Application Description
Enterprise JavaBeans 3.1
EJB 3.1 WAR-based Application

An EJB application that shows the use of WAR-based packaging , the no-interface Local view, Singleton session beans, and startup/shutdown callbacks.

EJB 3.1 Automatic Timer

An EJB Stateless Session Bean with a Remote business interface and a POJO Entity that demonstrates EJB 3.1 automatic timer feature.

Servlet 3.0
Servlet 3.0 Annotations Application

A Servlet 3.0 application using annotations for servlet, filter, and content listener.

Servlet 3.0 Asynchronous Application

A Servlet 3.0 application using asychronous API.

Servlet 3.0 Dynamic Registration of Servlets and Filters Application

A Servlet 3.0 application that features the dynamic registration of Servlets and Filters from a ServletContextListener.

Metro Web Services
Hello JAX-WS Application

An application demonstrates how JAX-WS 2.2 can generate artifacts dynamically and no use of wsgen is required when bundling and packing the artifacts.

EJB 3.1 Singleton Web Services Application

An application demonstrates a singleton EJB web service. It shows how easy it is to annotate a web service with @Singleton and develop clients for it.

Java API for RESTful Web Services
Message Board Application

An application that demonstrates the possibility to use no-interface EJB session beans as RESTful resource classes deployed as a servlet.

JavaServer Faces 2.0
Basic Ajax Application

A series of simple programs intended to illustrate some of the new Ajax features that are contained in JavaServer Faces 2.0.

Ajax Basic Composite Component Application

A series of simple programs intended to illustrate some of the new Composite Component features that are contained in JavaServer Faces 2.0.

Ajax Complete Application

A series of simple programs intended to illustrate some of the new Ajax features that are contained in JavaServer Faces 2.0.

JavaServer Faces 2.0 and Web Beans

JavaServer Faces 2.0 and Web Beans

Unmarshals an instance document into a Java content tree and accesses data contained within it. An application that demonstrates the use of Web Beans with JavaServer Faces 2.0.

Security

Web Security Annotations Application

A web application that demonstrates the access control annotations in servlets.

Programmatic Login Application

A web application that demonstrates the programmatic security (login/logout) feature in Servlets 3.0.

HTTP Method Omissions Application

A web application that demonstrates the use of http-method-omission feature of Servlet 3.0 to restrict the set of supported HTTP methods to just GET and POST.

Java EE Connector Architecture 1.6

MailConnector Resource Adapter Sample Application

An application using the mail-connector resource-adapter to retrieve e-mails. Demonstrates how to use new annotations introduced in Java EE Connector Architecture 1.6 specification. The mail connector resource adapter is completely built by specifying annotations. No deployment descriptor is used.

Java Persistence API 2.0

JPA Pessimistic Locking Application

An application that demonstrates the use of locking with Java Persistence APIs.



Java EE 5 Sample Applications

Download Java EE 5 Sample Applications
» Distribution Readme

Demonstrates the technologies and features specific to the Java Platform, Enterprise Edition 5. The features include annotations, EJB 3.0, persistence, security, web services and many others. Following is the current list of sample applications by technology category.

After downloading the samples bundle, install it under <sdk-install-root>/samples so that it looks like <sdk-install-root>/samples/javaee5. Remember to update <sdk-install-root>/samples/bp-project/build.properties before you start working on samples. If build.properties does not exist, you may copy it from build.properties.sample. Refer to <sdk-install-root>/samples/javaee5/index.html for details.


Sample Application Description
Enterprise Java Beans 3.0
annotation-override-interceptor-ear

Demonstrates how the order in which the interceptors are invoked can be altered using the deployment descriptor.

customer-cmp-ear

Demonstrates using Java Persistence APIs based on the new Java Persistence specification. The EJB interacts with a relational database to store and display information about customer subscriptions to periodicals.

interceptor-stateless-ear

A simple EJB 3.0 stateless session bean with a remote business interface that uses an EJB 3.0 interceptor mechanism to validate the parameter passed to a business method.

jsf-jpa-war

Demonstrates the use of Java Persistence APIs based on the new Java Persistence specification in conjunction with JavaServer Faces that creates a simple authentication scheme using JavaServer Faces PhaseListeners and a simple entity bean representing a user.

lottery-annotation-ear

A simple example that demonstrates the Java EE 5 annotation facility.

security-stateless-ear

A simple security example of an EJB 3.0 stateless session bean that uses annotations to specify the authorization.

servlet-stateless-ear

A simple EJB 3.0 stateless session bean with a local business interface invoked by a servlet. Demonstrates the concept of dependency injection, a new feature in Java EE 5.

web-jpa-war

Demonstrates the use of Java Persistence APIs based on the new Java Persistence specification within a servlet.

Web Services
hello-jaxws

A "hello world" web service example (the simplest possible example) using JAX-WS.

ssl-jaxws-ear

Demonstrates the creation of a secure JAX-WS web service endpoint (https) and accessing it using a Java application client. The service is protected at transport level and accessed by performing SSL server-side authentication.

JAXB

simple-jaxb

Unmarshals an instance document into a Java content tree and accesses data contained within it.



J2EE 1.4 Sample Applications

Download J2EE 1.4 Sample Applications
» Third Party License
» Updates

Demonstrates various technologies and features of J2EE 1.4 using small, technology-focused examples. Following is the current list of sample applications by technology category.

After downloading the samples bundle, install it under <sdk-install-root>/samples so that it looks like <sdk-install-root>/samples/j2ee14. Remember to update <sdk-install-root>/samples/j2ee14/common.properties before you start working with samples. Refer to <sdk-install-root>/samples/j2ee14/index.html for details.

Sample Application Description
quickstart Simple Hello World JSP example described in QuickStart Guide.
Web Applications
simple Basic JSP and servlet examples combined into a single web application.
caching Demonstrates how to cache results of JSP and servlet execution.

Security examples:
  basic-auth
  form-auth

See update

Basic authentication example (sub-directory security/apps/basic-auth).
Form-based authentication example (sub-directory security/apps/form-auth).
bookstore Demonstrates how to deploy and run Duke's Bookstore Sample Application.
Enterprise Java Beans

stateless-simple

Stateless session bean example.
stateful-simple Stateful session bean example.
cmpcustomer Entity beans using Container Managed Persistence (CMP).
BMP examples:
  simple
  robean
A simple Bean Managed Persistence (BMP) example (sub-directory bmp/apps/simple).
Example of read-only BMP beans (sub-directory bmp/apps/robean).
mdb-simple Message Driven Bean (MDB) example.
subclassing Demonstrates subclassing of Enterprise JavaBeans as a way of simplifying bean classes.
timersession A basic timer session bean example.
Java Web Services
JAX-RPC Three JAX-RPC web service applications using JAX-RPC.
WS-Security
Web services security samples
JNDI
custom Demonstrates using a custom JNDI resource factory.
external Demonstrates using an external JNDI resource factory.
url Demonstrates using a JNDI resource to connect to a URL.
XML Processing
dom Demonstrates using the XML document object model (DOM).
sax Demonstrates uising the Simple API for XML (SAX).
xslt Demonstrates using Extensible Stylesheet Language Transformation (XSLT).
Security Realms
realms Demonstrates using a custom security realm.
dynamicgroup Demonstrates using a Lightweight Directory Access Protocol (LDAP) security realm.
Java Database Connectivity (JDBC)
simple Basic servlet accessing an RDBMS via JDBC.
transactions EJB using the JDBC transaction API to control a local transaction.
Other Examples
jsf Three samples that demonstrate use of JavaServer Faces (JSF), which simplifies building user interfaces for rapid development of web applications.
mailconnector Illustrates how to create a Java EE Connector Architecture 1.5 compliant resource adapter (RA) (Inbound Connector).
rmi-iiop Using a Java application client to access a stateless EJB using RMI/IIOP.
soaptojms Illustrates using an application client to send and receive SOAP messages with JMS.
logging Demonstrates the use of Loggers in writing enterprise applications.
i18n Internationalization and Localization - How to dynamically change the display language of a web application based on user preference.
migration How to migrate an application to Sun Java System Application Server 9.0
acc Application Client Container (ACC): Refer to the sample in RMI-IIOP/simple for the use of ACC.


Other Samples

Samples for Project GlassFish
The Samples project provides relevant sample applications to demonstrate Java EE technology using the Java EE SDK built by the GlassFish Community. Developers can use and contribute to the sample applications.  

Java BluePrints
The Java BluePrints program defines the application programming model for end-to-end solutions using the Java Platform, Enterprise Edition (Java EE).
 
The Java Pet Store 2.0 Reference Application
This early access application is designed to illustrate how you can use the Java EE 5 platform to design and develop an AJAX-enabled Web 2.0 application. The application comes with full source-code available under a BSD-style license, so you can experiment with it and use it in your own applications.
 
Web Developer Resource Center: Samples
Check out these demos of sample applications, components, and widgets you can try in your next-generation web applications. Download the code and make them your own.
 
Tech Tips
Tech Tips present sample code solutions and techniques for developing in the Java Platform, Standard Edition (Java SE) and Java Platform, Enterprise Edition (Java EE).

Java EE SDK Fuels Efficiency - Get it Now

GlassFish AppServer - Get it Now

Download the NetBeans IDE

Getting Started
 
Related Resources
 
Open Project Glassfish