Results 1 to 4 of 4
- 10-17-2011, 07:37 AM #1
Member
- Join Date
- Oct 2011
- Posts
- 2
- Rep Power
- 0
Runtime Error - NoClassDefFoundError: <wrong name ...>
Hi All,
I am having trouble getting a user-defined class to work properly. The java compiles just fine but I get the following runtime error: NoClassDefFoundError: HelloWorld <wrong name...> ... etc. I'm sure this is related to the classpath setting but I can't seem to work it out.
The relevant source code in HelloWorld.java:
To the classpath variable I have added:Java Code:package examples.HelloWorld import com.sitename.helper.Helper;
HelloWorld.java and HelloWorld.class are contained in:Java Code:C:\Program Files\Java\sitename\classes\com\sitename\helper
The Helper.class is contained in the same directory structure as I have set in the classpath variable.Java Code:C:\Program Files\Java\sitename\examples\HelloWorld
I have searched for the info on how to figure this out but I have not found anything that is helping. I have no doubt this is a fairly common newbie error and I'm somewhat annoyed that I can't figure this out with the information I have at hand.
I'd really appreciate your help.
Thanks in advance,
Ben
- 10-17-2011, 08:06 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,398
- Blog Entries
- 7
- Rep Power
- 17
Re: Runtime Error - NoClassDefFoundError: <wrong name ...>
The full name of your class is examples.HeloWorld.HelloWorld and you should run it as such (i.e. including the package name).
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 10-17-2011, 10:03 AM #3
Member
- Join Date
- Oct 2011
- Posts
- 2
- Rep Power
- 0
Re: Runtime Error - NoClassDefFoundError: <wrong name ...>
Hi JosAH,
Thanks for your reply. Unfortunately, I am now getting "error: could not find or load main class: example.HelloWorld,HelloWorld". I get the same error no matter what variation of path or class name I use (eg example.HelloWorld).
I will stick at it.
Thanks,
Ben
- 10-17-2011, 10:10 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,398
- Blog Entries
- 7
- Rep Power
- 17
Re: Runtime Error - NoClassDefFoundError: <wrong name ...>
If your class is stored in /X/examples/HeloWorld/HelloWorld.class (X is any directory path) then your classpath variable should contain /X and you should start the class by doing:
Of course you should add any other classpath components needed by your program.Java Code:java -cp /X examples.HelloWorld.HelloWord
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
runtime error
By ashaudhaya in forum New To JavaReplies: 2Last Post: 11-12-2010, 10:13 AM -
Runtime Error
By mathfxr in forum New To JavaReplies: 8Last Post: 09-17-2010, 08:26 PM -
java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IProgressMonitor
By aznboarder in forum SWT / JFaceReplies: 1Last Post: 04-07-2009, 10:50 AM -
Diference Between compiler error Garbage collection and Runtime Error?
By makpandian in forum New To JavaReplies: 3Last Post: 01-23-2009, 08:53 AM -
java.lang.NoClassDefFoundError in Eclipse at runtime
By debu37 in forum New To JavaReplies: 5Last Post: 09-03-2008, 05:29 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks