Packages:Exception in thread "main" java.lang.NoClassDefFoundError

Posted on 2004-09-06
Last Modified: 2010-03-31
I have a class, Condit, which compiles and runs fine, when it is in the default package, but when I set it to be in package certification;
It compiles but when I try to run it this error comes up:
C:\java\certification>java Condit
Exception in thread "main" java.lang.NoClassDefFoundError: Condit (wrong name: j
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at Source)
        at Source)
        at$100(Unknown Source)
        at$ Source)
        at Method)
        at Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)


Any idea what I am doing wrong?

Question by:frankis
LVL 92

Expert Comment

ID: 11992744
you need to run it with:

java certification.Condit
LVL 92

Accepted Solution

objects earned 50 total points
ID: 11992748
you'll also need to add c:\java to your classpath if it is not there already.

Expert Comment

ID: 11994380
oh its a typical pkg problem

after compiling try
C:\java\java certification.condit

should work....

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.


Expert Comment

ID: 11994469

Hello Frankis..

 The problem may be for the following reasons

1)   Get one step back form your current directory then it looks like "c:\java"  here use  
java certification.condit

Author Comment

ID: 12000148
Thanks Objects, that seems to have done the trick, but I always thought that if you have a period in the classpath:
classpath=.;C:\certified etc

the class would run. How come it worked when it was default package?

LVL 92

Expert Comment

ID: 12001361
. (current directory) would work if you ran it from c:\java
add c:\java explicitly allows you to run from any directory

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 115
allswap challenge 6 99
mockito example issue 8 73
Java Timer (static) 9 45
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question