NoClassDefFoundError Exception

I have this probably very easy problem.

With this program
public class Hello {
        public static void main(String[] args) {
                System.out.println("Hello World");
        }
}
stored in Hello.java. Compiles OK, but gives this execution error:
Exception in thread "main" java.lang.NoClassDefFoundError: Hello/class

What's wrong?
LVL 1
pagerbakAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jan LouwerensSoftware EngineerCommented:
do you hava a classpath variable set? If you do, make sure that you have the current directory specified in it.

classpath=./;...
0
pagerbakAuthor Commented:
No, I hadn't, but it didn't make any diffence.
I tried
SET CLASSPATH=./;...  (isn't there a dot too many here?)
SET CLASSPATH=./;..    
SET CLASSPATH=.
I'm running Jdk1.2.2 on Win98. I think I saw somewhere, that java will look in the current directory for classes, (is this btw correct?).

0
pagerbakAuthor Commented:
No, I hadn't, but it didn't make any diffence.
I tried
SET CLASSPATH=./;...  (isn't there a dot too many here?)
SET CLASSPATH=./;..    
SET CLASSPATH=.
I'm running Jdk1.2.2 on Win98. I think I saw somewhere, that java will look in the current directory for classes, (is this btw correct?).

0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

conickCommented:
It looks like you are including the extension when you run the program.  Do you do something like this:
java Hello.class
or is it
java Hello

The second one is correct.  The first one will display the error.
When you compile you need the extension, when you run it you cannot have it. (unless you do jar files)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pagerbakAuthor Commented:
Thank you very much. I knew it was something simple. Just couldn't see it.
0
Jan LouwerensSoftware EngineerCommented:
glad you got your answer, pagerbak. The ... at the end of the classpath I specified above were actually supposed to be elipses, not a path.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.