Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Exception in thread "main" java.lang.NoClassDefFoundError: myfile/class

  Asked By: Willie    Date: Feb 01    Category: Java    Views: 1847
  

I have J2SE. Everytime I try to run one of my programs it says:

Exception in thread "main" java.lang.NoClassDefFoundError:
myfile/class

How can i fix this problem? Any help would be greatly apprieciated.

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Ruairidh Anderson     Answered On: Feb 01

When trying to run  a java  program, you ommit the ".class" at the end of
the class name e.g.

java myfile

assuming that the class myfile.class is in your current directory and
myfile.class does not specifiy a package e.g. package com.tld.abc;

If you have specified myfile to be in package com.tld.abc then the command
would be

java com.tld.abc.myfile

 
Answer #2    Answered By: Jay Richards     Answered On: Feb 01

Add exception  for invalid number.
You seems to be using C syntax for printf, check out System.out.println
API

 
Answer #3    Answered By: Wade Jordan     Answered On: Feb 01

printf is not a Java function. Use print or println
instead. See the Java SDK docs for more info.

Other than that, what problems are you having?

 
Answer #4    Answered By: Roderick King     Answered On: Feb 01

Java 5 does have printf() (see PrintStream and PrintWriter).

To post authors: please tell us what JDK you are working with in order
to receive accurate responses.