Two Laptop Bag*
The moose likes Beginning Java and the fly likes NoClassDefFound-wrong name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NoClassDefFound-wrong name" Watch "NoClassDefFound-wrong name" New topic
Author

NoClassDefFound-wrong name

saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
i am working with web services and i am trying to test them, i am shocked to get the following exception, the thing is there is a Test.java file in a package and build the class using ant build.xml the Test.java consist of main method but i am facing the following error and i checked many a times the source file name with the class name, and named them by copying from what i have typed but still
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

What is exactly the command that you typed in to run your application? Try this instead:

java -classpath build\classes org.apache.ws.axis2.Test

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
no change
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What is your directory structure (source and build), and how are you trying to run it? It's definitely a classpath issue; it looks like it's trying to run something with the classpath set up the hierarchy too far.
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
here is my directory structure
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
In that case, the command given by Jesper should work assuming that the current directory is the top-level one (in which "src" and "classes" reside).


Ping & DNS - my free Android networking tools app
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

David Newton wrote:how are you trying to run it?
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
when i am running through the prompt by changing the directory to the appropriate location and run in the usual way i am getting the error which i have specified earlier but when i am using an IDE i am getting the following error.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

"The usual way"? How would I know what your "usual way" is? TellTheDetails. Don't make us guess what you're doing--it makes it very painful to help.
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
sorry if i am providing less information

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And your classpath is? Where are you in your directory hierarchy when you try to run?
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
HelloService is the root directory

when i am running the File Test.class i will in the location
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41108
    
  45
java Test

This can't possibly work, since the class is part of the org.apache.ws.axis2 package. Try "java org.apache.ws.axis2.Test" instead.

You need to change into the "HelloService" directory first, and then the command posted by Jesper will work.
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
i have tried in your way
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

*sigh*
Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317
change to

drive:\XXXX\HelloService


and then run

java -classpath build\classes org.apache.ws.axis2.Test
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
this is really the problem with the classpath and the location i am using, the one you have said is working.
even earlier one of the member asked me to do the same but the location made the difference.
thanks for every one who took the risk and pain to help me.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
Are you running from Eclipse? That is the only place I have seen Unresolved compilation problems.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

Or any other IDE that allows you to run code without solving compiler errors. And this is why you never should run an application while there are still compiler errors; you should always solve these before trying to run your application. Any application with compiler errors will always be broken.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: NoClassDefFound-wrong name
 
Similar Threads
Loading and instantiating a remote class?
Jar issue - NoClassDefFoundError when attempting to run. Class-Path set in MANIFEST.MF
NoClassDefFoundError
Package Headache
Axis 2 tutorial - client class compliation error