0

Possible Duplicate:
Can I run from command line program created by Eclipse?

I am getting below exception when I try to run class file from command prompt,the same I run in eclipse,there I don't get any error

Trying to run from the same folder

 Exception in thread "main" java.lang.NoClassDefFoundError: testClient (wrong nam
    e: com/mindcraft/queryExecutor/actionclass/testClient)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClassCond(Unknown Source)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$000(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: testClient.  Program will exit.
Community
  • 1
  • 1
happy
  • 2,550
  • 17
  • 64
  • 109

3 Answers3

5

I suspect you're running in a directory of com/mindcraft/queryExecutor/actionclass

Instead, you should be running in the root directory (i.e. the parent of com), like this:

java com.mindcraft.queryExecutor.actionclass.testClient
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • tried the same ,still getting the same error. – happy Jun 19 '12 at 09:16
  • @happy: I very much doubt that you're getting the *same* error, if you ran exactly what I said. Of course, you've hardly given us any information, which makes it hard to go on... you haven't told us how you're building, what you're trying to run etc. – Jon Skeet Jun 19 '12 at 09:21
2

run the .class file from root directory with full name space. i.e, if your class is in com.test package as com.test.App.java in your src then on compiling its class file will have a qualified class name as full name. i.e, com.test.App.class

So from your root/src run it as java com.test.App in command line.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
Chakradhar K
  • 501
  • 13
  • 40
0

Before posting a question kindly Search enough if the question has been asked before or even better answered before. When i Googled i found a similar question being answered. Hope the link provides you the answer you are looking for

Community
  • 1
  • 1
anthoon
  • 101
  • 9