Thanks a million,Gisbert!
That's very helpful.
Best Regards,
Jason

-----Original Message-----
From: Gisbert Amm [mailto:[EMAIL PROTECTED]
Sent: 23 January 2006 11:14
To: Maven Users List
Subject: Re: Exception in thread "main" java.lang.NoClassDefFoundError:
?? ??


Zheng Wen Zhe wrote:
> Sorry,my fault! 
> Just mis-typed "target".Class App is executed successfully this time with
> command:C:\my-apps\genapp>java -cp target\test-application-1.0.jar
> mdn.testapp.App;

That's what I reckoned ;-)

> Does this mean i have to use -cp parameter everytime executing a clas?

The jar has to be on your classpath, yes. Usually one uses some script 
to achieve that (*.bat on Windows). Alternatively, you can set the 
CLASSPATH environment variable. I recommend reading something like 
http://mindprod.com/jgloss/classpath.html

> And,I
> found it didnt make any difference by setting
> "maven.jar.manifest.extensions.add=true"

It's the maven.jar.mainclass attribute that makes sure that the main 
class entry is added to the jar's manifest. About the manifest see e.g. 
http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#JAR%20Manifest (the 
first doc I found; there might be a newer one).

Try to call the jar with "java jar" then (the jar tool). See e.g. 
http://java.sun.com/j2se/1.3/docs/tooldocs/win32/jar.html (the same 
comment as above).

-Gisbert

> -----Original Message-----
> From: Gisbert Amm [mailto:[EMAIL PROTECTED]
> Sent: 23 January 2006 10:43
> To: Maven Users List
> Subject: Re: Exception in thread "main" java.lang.NoClassDefFoundError:
> ?? ??
> 
> 
> The main class is still not found.
> 
> Did you type "tartget" (mind the "t") at the commandline? Try it again 
> with "target".
> 
> How does your jar look like? Does App.class sit within mdn/testapp?
> 
> Does App.java in your project really reside within src/java/mdn/testapp?
> 
> -Gisbert
> 
> Zheng Wen Zhe wrote:
> 
>>I run the command again with -cp parameter,but got a different error??
>>do you have any clue about it?
>>
>>Regards,
>>Jason
>>**********************
>>C:\my-apps\genapp>java -cp tartget\test-application-1.0.jar
> 
> mdn.testapp.App;
> 
>>Exception in thread "main" java.lang.NoClassDefFoundError:
> 
> mdn/testapp/App;
> 
>>-----Original Message-----
>>From: Gisbert Amm [mailto:[EMAIL PROTECTED]
>>Sent: 23 January 2006 10:22
>>To: Maven Users List
>>Subject: Re: Exception in thread "main" java.lang.NoClassDefFoundError:
>>????
>>
>>
>>Setting the classpath could also help:
>>
>>C:\my-apps\genapp\test-app>java -cp target\test-app-1.0.jar
> 
> mdn.testapp.App
> 
>>Regards,
>>Gisbert Amm
>>
>>Gisbert Amm wrote:
>>
>>
>>>You probably want to set the maven.jar.mainclass attribute to get the 
>>>main class entry written to the jar manifest file. See
>>>http://maven.apache.org/maven-1.x/reference/plugins/jar/properties.html
>>>
>>
>>
>>Here you would call the jar directly:
>>
>>C:\my-apps\genapp\test-app>java jar target\test-app-1.0.jar
>>
>>
>>
>>>>Hi,
>>>>I experienced an exception Error while executing the App class of my
>>>>project.
>>>>Could any body give some advice? where is the fault?
>>>>
>>>>Regards,
>>>>Jason
>>>>
>>>>******************************** 1.Run maven genapp to execute genapp 
>>>>goal to create a new project;
>>>>2.execute jar goal with maven jar;
>>>>3.execute App class with >java tartget\test-application-1.0.jar
>>>>mdn.testapp.App;
>>>>
>>>>Error message from console:
>>>>C:\my-apps\genapp\test-app>java target\test-app-1.0.jar mdn.testapp.App
>>>>Exception in thread "main" java.lang.NoClassDefFoundError:
>>>>target\test-app-1/0/jar
>>>>
>>>>The expect result is: "Hello world!" displaying in console.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to