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.
3
  • Does the folder contain a file called testClient.class? Commented Jun 19, 2012 at 9:05
  • 1
    Make sure you have all the classes and the libraries you need in the classpath. In eclipse, you have this information on the Build Path. Commented Jun 19, 2012 at 9:06
  • What does this have to do with RMI? Commented Jun 19, 2012 at 9:09

3 Answers 3

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
Sign up to request clarification or add additional context in comments.

2 Comments

tried the same ,still getting the same error.
@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.
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.

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.