Question by Michael M: exception in thread “main”?
I have this program I was given to work on in my class. I have no idea what any of it means, because they just wanted me to get used to the javac and java comands. I have saved my program “Limits.java” and compiled it so that I have “Limits.class”. They are both in the path “C:\Documents and Settings\owner\.jedit\”. When I try to do the java comand in my prompt, I get an error “Exception in thread “main” java.lang.NoClassDefFoundError… Limits/java” in my command prompt. I am in “C:\Documents and Settings\owner\.jedit>” on my command prompt. Do I have to set the class path, because I think I changed it in environmental variables when I was trying to get the path set for javac by accedent. If that has nothing to do with my problim just ignore it. Always beter to have too much information than not enough.
I have also entered java Limits and I stell get the error. I have alos set the class path in the environmental variables to be C:\Program Files\Java\jdk1.6.0\bin and I still get the same error. I am in the C:> derectory for my comand prompt. Ok so my program is below.

/* Limits.java: Determine machine percison */
public class Limits
{ public static void main( String [] args)
{ final int N=60;
int i;
double eps=1.0, one_Plus_Eps;
for (i=0; i

4 thoughts on “exception in thread “main”?”

  1. Michael you already know the answer to your problem… Yes its the classpath which you have to correct… change it to C:bin;.;

    and it will be ok

  2. Show us the command line you are using. It isn’t finding your class. It could be that you need to set the CLASSPATH (-cp), but if you’ve typed the error message correctly, I think you typed in the command wrong.

    You want something like this:

    java Limits

    not “java Limits/java” or “java Limits.java” or “java Limits.class”

  3. You typed in command wrong:
    This is what you typed:
    java Limits.java
    This is supposed to be the command:
    java Limits

    There is no .java or anything after and including . with java command

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.