• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

not able to run simple java program

 
kesava chaitanya
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i have written simple java program;i am using JDK 1.3.1 version;i am running this program on WindowsME;i set the classpath properly;compiled well; but when i run the program i get the NoClassDefFoundError;how can i solve this problem
bye
chaitanya
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The surely looks like a Classpath problem. Make sure that everything is set properly (check capitalization, as well). If you have the class defined in a package, is it placed in the proper directory structure to mimic that package? (i.e. foo.bar.baz.TestClass should be in C:\foo\bar\baz.)
Corey
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've noticed that many programmers new to packages in Java will compile the source files just fine, put the class files in the appropriate directory structure according to the package declarations, then fail to run a specified class file from the appropriate directory.
In other words, if the file Hello.class belongs to the package fred and is in fact in a directory named fred, the programmer will try to run the class Hello.class from within the directory fred like so:
c:\fred>java Hello
or
c:\fred>java fred.Hello
which will not work. The proper place to run Hello from is from the parent directory of fred like so:
c:\>java fred.Hello
But perhaps this is not your problem...
Good Luck.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another point to be wary of that could produce the exception that is causing you troubles:
Don't specify the .class file extension when running a Java program like this:
c:\>java Hello.class
rather do it like this:
c:\java Hello
Good Luck.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic