Posted here
j2ee.jar has the interface definitions for Java EE v1.4 specification whereas javaee.jar has the interface definitions for Java EE v1.5 (the name has been simplified to Java EE v5). So when you are developing an application that uses JEE v1.4 then you will need j2ee.jar on your classpath when compiling (do not need to package it in the module when deploying). And when you are developing an application that uses JEE v5 then you will need javaee.jar on your classpath when compiling (do not need to package it in the module when deploying).
The next two questions that might come to your mind are:
1. How do you know which JEE version you are using for development?
The j2ee.jar and javaee.jar files are just API deifinitions (interfaces, and abstract classes) for the corresponding Java EE versions (i.e. 1.4 and 5 respectively). These APIs were designed by SUN and specify a contract between a Java EE container and the applications that will be deployed on the container. The implementation of this contract is provided by the various application server vendors. For example, Glassfish v2ur2 implements BOTH versions, however it requires you to specify, in the deployment descriptions, the JEE version which is to be used for the application that you are deploying.
So in short the version of JEE you are using is specified in the deployment descriptor for the application.
2. Why do we need these jars only during compilation and do not need to add it to the war (or jar) when deploying our module to the app server?
The reason is that it will already be available in the app server that you are deploying you application to. This seems quite obvious as if i provide implementation of an interface, i will need to give you the interface as well as you will actually be using my implementation via the interface and not by directly calling my implementation classes. If you directly call my implementation classes then it will beat the whole purpose of defining a standard interface that everyone can use.
The next two questions that might come to your mind are:
1. How do you know which JEE version you are using for development?
The j2ee.jar and javaee.jar files are just API deifinitions (interfaces, and abstract classes) for the corresponding Java EE versions (i.e. 1.4 and 5 respectively). These APIs were designed by SUN and specify a contract between a Java EE container and the applications that will be deployed on the container. The implementation of this contract is provided by the various application server vendors. For example, Glassfish v2ur2 implements BOTH versions, however it requires you to specify, in the deployment descriptions, the JEE version which is to be used for the application that you are deploying.
So in short the version of JEE you are using is specified in the deployment descriptor for the application.
2. Why do we need these jars only during compilation and do not need to add it to the war (or jar) when deploying our module to the app server?
The reason is that it will already be available in the app server that you are deploying you application to. This seems quite obvious as if i provide implementation of an interface, i will need to give you the interface as well as you will actually be using my implementation via the interface and not by directly calling my implementation classes. If you directly call my implementation classes then it will beat the whole purpose of defining a standard interface that everyone can use.
No comments:
Post a Comment