The moose likes Beginning Java and the fly likes Run java class that lives in .ear Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Run java class that lives in .ear" Watch "Run java class that lives in .ear" New topic
Author

Run java class that lives in .ear

Bobby Anderson
Ranch Hand

Joined: Oct 28, 2008
Posts: 114
So I have a main inside one of my java classes. It is packaged in a jar(test.jar) and that jar is placed in an ear(test.ear). The ear is deployed to the server.

Now I want to run that classes main by using the ear in my classpath. I know that if I just used the jar I could get to that class but the jar is in the ear already and I don't really want to put the jar in two places.



java -cp $JBOSS_HOME/server/all/farm/test.ear com.test.SomeTest

When I do this I get the dreaded class not found error.

Anyone have a good way to say "come on java just look at all the .jar(s) in the ear archive to find that class.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16687
    
  19


Unless this is a new feature just added to Java, you can't do it. You have to extract the files in the EAR file, so that you can have access to the JAR files...

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Run java class that lives in .ear
 
Similar Threads
Websphere 6 and IBM webserver
Jdom Servlet Classloading Error
Are jars in EAR available
very very urgent...pl respond..
Java Applets as Application Clients