Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Jar file execution problem

Status
Not open for further replies.

sudhakarpothu

Programmer
Jan 8, 2007
19
DE
Hello friends,

I have a project folder in which i have 4 packages

application
ui
controller
model and
a folder Datafile containing project related xml and text files

my main class is in application package

I am creating a jar file of my whole project folder in Eclipse environment, using the main class as TheApplication in application package. I am able to generate the jar file but unable to execute it.

When I tried to execute it from command prompt it is giving me an error saying no main,

Please tell me what I am doing wrong, and suggest me a solution

Thanks in advance
 
I have already tried all those but something seems to be wrong, May be i need to put all my class files in one folder
 
Post the actual error, the way you're executing the jar and the way you're setting the main class.

Cheers,
Dian
 
I have a Exception

Exception in thread "AWT-EventQueue-0" java.lang.noclassdeffounderror: org/jdom/Document

I added jdom.jar in my libraries from before

I dont know whats wrong,

I am running it from command prompt

java -jar project.jar

manifest is

Manifest-Version: 1.0
Main-Class: oopsProjectApplication.TheApplication

any suggestions

 
Manifest has to be:
Code:
Manifest-Version: 1.0
Main-Class: oopsProjectApplication.TheApplication
Class-Path: ../lib/jdom123.jar:../.lib/jdom345.jar
a) I'm not sure, whether .. is allowed inside a Manifest, to specify the classpath.
b) Look for the exact syntax (Classpath, Class-Path) in the Javadocs.
c) Is it a good idea, to specify inside a jar (often solely shipped without third party jars) where the user might have installed these jars?

Perhaps a better way would be, to put all jdom-related jars in $JAVA_HOME/jre/lib/ext/.


don't visit my homepage:
 
You can specify a classpath in your manifest, but that will make jar not portable as the path of the related jars is fixed.

Better include a kind of documentation to specify which jars need to be added to the classpath.

Cheers,
Dian
 
Hi StefanWagnar,

your idea

Perhaps a better way would be, to put all jdom-related jars in $JAVA_HOME/jre/lib/ext/.

worked out perfectly,

thanks a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top