0
# Java EE API
1
2
Java EE API is the complete Java Enterprise Edition 8 specification implementation providing all standardized enterprise application development interfaces in a single unified library. It combines Web Profile APIs with additional Full Profile enterprise technologies, enabling developers to build comprehensive enterprise applications with standardized APIs for web services, persistence, messaging, security, and transaction management.
3
4
## Package Information
5
6
- **Package Name**: javaee-api
7
- **Package Type**: Maven
8
- **Language**: Java
9
- **Installation**: Add to your `pom.xml`:
10
11
```xml
12
<dependency>
13
<groupId>javax</groupId>
14
<artifactId>javaee-api</artifactId>
15
<version>8.0.1</version>
16
<scope>provided</scope>
17
</dependency>
18
```
19
20
## Core Imports
21
22
Java EE APIs are accessed through their respective package namespaces:
23
24
```java
25
// Servlet API
26
import javax.servlet.*;
27
import javax.servlet.http.*;
28
29
// Enterprise JavaBeans
30
import javax.ejb.*;
31
32
// Java Persistence API
33
import javax.persistence.*;
34
35
// JAX-RS (RESTful Web Services)
36
import javax.ws.rs.*;
37
38
// CDI (Contexts and Dependency Injection)
39
import javax.enterprise.context.*;
40
import javax.inject.*;
41
42
// JSON Processing and Binding
43
import javax.json.*;
44
import javax.json.bind.*;
45
46
// Web Services (JAX-WS)
47
import javax.jws.*;
48
import javax.xml.ws.*;
49
50
// XML Binding (JAXB)
51
import javax.xml.bind.*;
52
import javax.xml.bind.annotation.*;
53
```
54
55
## Basic Usage
56
57
```java
58
// Basic servlet example
59
@WebServlet("/hello")
60
public class HelloServlet extends HttpServlet {
61
@Override
62
protected void doGet(HttpServletRequest request, HttpServletResponse response)
63
throws ServletException, IOException {
64
response.getWriter().println("Hello, Java EE!");
65
}
66
}
67
68
// JAX-RS REST endpoint
69
@Path("/api/users")
70
@ApplicationScoped
71
public class UserResource {
72
73
@Inject
74
private UserService userService;
75
76
@GET
77
@Produces(MediaType.APPLICATION_JSON)
78
public List<User> getUsers() {
79
return userService.findAll();
80
}
81
}
82
83
// JPA Entity
84
@Entity
85
@Table(name = "users")
86
public class User {
87
@Id
88
@GeneratedValue(strategy = GenerationType.IDENTITY)
89
private Long id;
90
91
@Column(nullable = false)
92
private String name;
93
94
// getters and setters
95
}
96
```
97
98
## Architecture
99
100
Java EE 8 API is organized into two main profiles:
101
102
- **Web Profile**: Core APIs for web application development (Servlet, JSP, JSF, JAX-RS, JPA, CDI, etc.)
103
- **Full Profile**: Web Profile + additional enterprise APIs (JMS, JavaMail, JCA, Batch, etc.)
104
105
The API provides standardized interfaces that are implemented by Java EE application servers like GlassFish, WildFly, WebLogic, and WebSphere.
106
107
## Capabilities
108
109
### Web Technologies
110
111
Web layer APIs for building user interfaces and handling HTTP requests including servlets, JSP, JSF, and WebSocket support.
112
113
```java { .api }
114
// Servlet API
115
public abstract class HttpServlet extends GenericServlet;
116
public interface HttpServletRequest extends ServletRequest;
117
public interface HttpServletResponse extends ServletResponse;
118
119
// JSF API
120
public abstract class UIComponent implements StateHolder;
121
public abstract class FacesContext;
122
123
// WebSocket API
124
@ServerEndpoint(value="/websocket")
125
public class WebSocketEndpoint;
126
```
127
128
[Web Technologies](./web-technologies.md)
129
130
### RESTful Web Services
131
132
JAX-RS API for building RESTful web services with annotation-driven development and comprehensive client API.
133
134
```java { .api }
135
@Target({ElementType.TYPE, ElementType.METHOD})
136
@Retention(RetentionPolicy.RUNTIME)
137
@HttpMethod("GET")
138
public @interface GET;
139
140
public interface Response;
141
public abstract class Application;
142
```
143
144
[RESTful Web Services](./rest-services.md)
145
146
### Enterprise JavaBeans
147
148
EJB API for developing enterprise business components with transaction management, security, and lifecycle support.
149
150
```java { .api }
151
@Target({ElementType.TYPE})
152
@Retention(RetentionPolicy.RUNTIME)
153
public @interface Stateless;
154
155
@Target({ElementType.TYPE})
156
@Retention(RetentionPolicy.RUNTIME)
157
public @interface Stateful;
158
159
public interface EJBContext;
160
```
161
162
[Enterprise JavaBeans](./ejb.md)
163
164
### Java Persistence
165
166
JPA API for object-relational mapping, entity management, and database operations with JPQL query language.
167
168
```java { .api }
169
@Target({ElementType.TYPE})
170
@Retention(RetentionPolicy.RUNTIME)
171
public @interface Entity;
172
173
public interface EntityManager;
174
public interface Query;
175
public interface TypedQuery<X>;
176
```
177
178
[Java Persistence](./persistence.md)
179
180
### Dependency Injection
181
182
CDI and javax.inject APIs for dependency injection, contextual lifecycle management, events, and interceptors.
183
184
```java { .api }
185
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
186
@Retention(RetentionPolicy.RUNTIME)
187
public @interface Inject;
188
189
public interface BeanManager;
190
public interface Instance<T>;
191
```
192
193
[Dependency Injection](./dependency-injection.md)
194
195
### JSON Processing
196
197
JSON-P and JSON-B APIs for parsing, generating, and binding JSON data with streaming and object mapping support.
198
199
```java { .api }
200
public interface JsonReader extends Closeable;
201
public interface JsonWriter extends Closeable;
202
public final class Json;
203
204
// JSON Binding
205
public interface Jsonb extends AutoCloseable;
206
public final class JsonbBuilder;
207
```
208
209
[JSON Processing](./json-processing.md)
210
211
### Messaging
212
213
JMS API for asynchronous messaging with support for queues, topics, and message-driven beans.
214
215
```java { .api }
216
public interface ConnectionFactory;
217
public interface Connection extends AutoCloseable;
218
public interface Session extends Runnable, AutoCloseable;
219
public interface MessageProducer extends AutoCloseable;
220
public interface MessageConsumer extends AutoCloseable;
221
```
222
223
[Messaging](./messaging.md)
224
225
### Transaction Management
226
227
JTA API for declarative and programmatic transaction management with XA resource coordination.
228
229
```java { .api }
230
public interface UserTransaction;
231
public interface TransactionManager;
232
public interface Transaction;
233
```
234
235
[Transaction Management](./transactions.md)
236
237
### Security
238
239
Security APIs including JACC authorization, JASPIC authentication, and Java EE Security for identity management.
240
241
```java { .api }
242
// JACC
243
public abstract class Policy;
244
public interface PolicyContext;
245
246
// Java EE Security
247
public interface IdentityStore;
248
public interface HttpAuthenticationMechanism;
249
```
250
251
[Security](./security.md)
252
253
### Validation
254
255
Bean Validation API for validating JavaBeans using constraint annotations and validation groups.
256
257
```java { .api }
258
public interface Validator;
259
public interface ValidatorFactory;
260
261
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
262
@Retention(RetentionPolicy.RUNTIME)
263
public @interface NotNull;
264
```
265
266
[Validation](./validation.md)
267
268
### Web Services
269
270
JAX-WS API for building SOAP-based web services with annotation-driven development, comprehensive client support, and WSDL generation.
271
272
```java { .api }
273
@Target({ElementType.TYPE})
274
@Retention(RetentionPolicy.RUNTIME)
275
public @interface WebService {
276
String name() default "";
277
String targetNamespace() default "";
278
String serviceName() default "";
279
String portName() default "";
280
String wsdlLocation() default "";
281
String endpointInterface() default "";
282
}
283
284
public class Service {
285
public static Service create(URL wsdlDocumentLocation, QName serviceName);
286
public <T> T getPort(QName portName, Class<T> serviceEndpointInterface);
287
public <T> Dispatch<T> createDispatch(QName portName, Class<T> type, Service.Mode mode);
288
}
289
```
290
291
[Web Services](./web-services.md)
292
293
### XML Binding
294
295
JAXB API for binding Java objects to XML representations with annotation-driven marshalling and unmarshalling support.
296
297
```java { .api }
298
public abstract class JAXBContext {
299
public static JAXBContext newInstance(String contextPath) throws JAXBException;
300
public static JAXBContext newInstance(Class... classesToBeBound) throws JAXBException;
301
public abstract Marshaller createMarshaller() throws JAXBException;
302
public abstract Unmarshaller createUnmarshaller() throws JAXBException;
303
}
304
305
@Target({ElementType.TYPE, ElementType.PACKAGE})
306
@Retention(RetentionPolicy.RUNTIME)
307
public @interface XmlRootElement {
308
String name() default "##default";
309
String namespace() default "##default";
310
}
311
```
312
313
[XML Binding](./xml-binding.md)
314
315
### Enterprise Services
316
317
Additional enterprise APIs including JavaMail, JCA connectors, batch processing, and concurrency utilities.
318
319
```java { .api }
320
// JavaMail
321
public abstract class Message implements Part;
322
public abstract class Transport;
323
324
// Batch Processing
325
public interface JobOperator;
326
public interface StepContext;
327
328
// Concurrency
329
public interface ManagedExecutorService extends ExecutorService;
330
```
331
332
[Enterprise Services](./enterprise-services.md)