This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Running from EAR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Running from EAR" Watch "Running from EAR" New topic
Author

Running from EAR

Tiago Fernandez
Ranch Hand

Joined: May 16, 2003
Posts: 167
Hello all,

I'd like to know if it's possible to run an application from an EAR file. If so, how do I do it? Currently, I get an "Exception in thread "main" java.lang.NoClassDefFoundError".

My EAR file contains all the libraries bound on APP-INF/lib, and the JAR file with the Main-Class correctly set on the "/", the root. Outside the EAR file, it works fine.

Can anybody help?

Thanks in advance!


Tiago Fernandez
http://www.tiago182.spyw.com/
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Is the EAR file in the CLASSPATH ?


[My Blog]
All roads lead to JavaRanch
Tiago Fernandez
Ranch Hand

Joined: May 16, 2003
Posts: 167
Yes, it is... I guess I'm still missing something.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30405
    
150

Tiago,
The Java file would be in a jar (an ear uses the jar format) within a jar (the code itself would be in a jar file.) I'm not sure whether you can do this, but I suspect not. I'll be keeping an eye on this thread to see if someone else knows.

When you deploy the ear, it is unzipped/jar'd. Then you have loose jars for your libraries. At this point, it is definitely possible to run a Java program - main method.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Clifton Craig
Ranch Hand

Joined: May 26, 2006
Posts: 103
Tiago,

An EAR file is meant for deployment on an appserver. It typically contains jar files that describe EJBs and/or web warchives (WAR files). The standard Java runtime will not execute an EAR file similar to a Jar file so you cannot pass it on the command line to the java executable. You may drop it into an application server like JBoss or WebSphere, assuming it is properly constructed and includes all of the relevant deployment XML files. What you are probably looking for is a solution like One Jar which allows you to nest jar files in one another. Hope that helps some


Holla at me...<br /><a href="http://codeforfun.wordpress.com" target="_blank" rel="nofollow">http://codeforfun.wordpress.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running from EAR