Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Spring and the fly likes NoClassDefFoundError: org/springframework/context/ApplicationContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "NoClassDefFoundError: org/springframework/context/ApplicationContext" Watch "NoClassDefFoundError: org/springframework/context/ApplicationContext" New topic
Author

NoClassDefFoundError: org/springframework/context/ApplicationContext

Rohit Rai
Ranch Hand

Joined: Aug 04, 2008
Posts: 53
Hi,

I have just started working on springs and have done my first "Hello World" example. It is working fine - one place that i am getting stuck with is do i need to set the spring.jar and related jar's in my classpath in order to execute it from the command line?

The sample program works fine in Eclipse - but now i have made a jar and want to execute it from the command line and i am getting the following error - i tried to set the springs.jar to the classpath but its not working - what am i missing - [this is bugging ]

C:\>java -jar rohit.jar

Adam Koblentz
Greenhorn

Joined: Mar 18, 2011
Posts: 19

Are you sure you're exporting the jar correctly?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Yes, you need the Spring jars in your classpath in order for it to find Spring classes.

And it is Spring. There is no pluralization of it. It is the Spring Framework.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Rohit Rai
Ranch Hand

Joined: Aug 04, 2008
Posts: 53
Thanks for the inputs - yes we need to put the jar's in the class path
Rohit Rai
Ranch Hand

Joined: Aug 04, 2008
Posts: 53
By the way an update on this - i was using maven for the build ... so finally i figured a way out for this . while creating the jars put in all the dependent jars - i am not too sure if it's the correct approach but since the program that i was trying to do is a standalone one i thought of using it ... in pom.xml you can use the following plugin



and create the jar using



and execute as you normally do using
 
Consider Paul's rocket mass heater.
 
subject: NoClassDefFoundError: org/springframework/context/ApplicationContext
 
Similar Threads
Error with execution using packages in command line
SwingSet3
Run time error
Question No. 11- Chapter 10 K&B book SCJP 1.6 - Doubt on Answer
Basic CLASSPATH problem on Mac OS X