For the example you quote that is what you ought to write. It also presume it actually said . . . NoClassDefFoundErrorEx because you must type the class name exactly the way it is spelt in the Java code, without a . or extension.
I don't think you have an installation problem; that usually produces an error message like "java is not recognised . . .". Please check your classpath that it contains a dot; on Windows it would include ;.; and on Linux/Mac/Unix :.: also making sure there are no extraneous spaces eg ; .; or :. : I don't think it matters if the same thing appears twice in the classpath.
Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.
The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.
You haven't managed to move or delete the .class file, have you? Explore the folder you happen to be in at the present, and make sure it contains files called Ex.java and Ex.class (or use "ls" in Linux, or "dir" on Windows which should show the folder's contents).
First, a bit of business: you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. "Handles" aren't acceptable. You can change your display name here. Thanks!
As to your question: this is a very common problem. You, or some other software, has set the CLASSPATH environment variable (which tells Java where to look for class files) so that it doesn't include the current directory. You need an entry of just "." (a period) to stand for this. You might find this helpful.
Hi, I am aware that Marc is one of the most talented heads out there and this question means i went wrong somewhere. but i wanted to say that it is just a convention to have the class with the main method to be declared public. No access modifier means the class has a default access.And in a Java file only on class can be public but there can be n number of non-public classes. As far as i know..
Originally posted by Amit Ghorpade: ...it is just a convention to have the class with the main method to be declared public. No access modifier means the class has a default access...
Yes, it might be a good idea to make the main class public. But default access would not cause the problems that the original poster was having. So there's nothing "wrong" with the suggestion -- I just thought it needed some clarification about why "public" makes sense (which you provided above).