Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

.jar or .ear ?

 
Frank Sikuluzu
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
New to EJB. Couple of simplest questions ---

I know if I have a web application, I put everything in a .war file. If

1. my application is an EJB without any web application, should I put everything in a .ear or a .jar ?

2. my application is an EJB including web application, should I first put the web application in a .war, then combine the .war with the EJB classes and others into a .ear or into a .jar ?

please kindly answer separately for above scenarios.

thanks,
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frank,
1. It depends on how you are going to deploy it. If you are deploying the EJB as an application, put it in an .ear. If you are giving it to someone else to use, put in a jar. Note that this special type of jar is called and ejb jar.
2. Yes, put the web app in a war first. Then put the ejb in a jar. Finally, put both in an ear.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. my application is an EJB without any web application, should I put everything in a .ear or a .jar ?


By default of EJB , you can packaged into jar file.

And you can packaged into EAR file.

EAR file
- application.xml
- jar file
- META-INF / ejb-jar.xml
- war file
- WEB-INF / web.xml
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2. my application is an EJB including web application, should I first put the web application in a .war, then combine the .war with the EJB classes and others into a .ear or into a .jar ?

Both, depend on you and requirement.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic