aspose file tools*
The moose likes Beginning Java and the fly likes not able to run simple java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "not able to run simple java program" Watch "not able to run simple java program" New topic
Author

not able to run simple java program

kesava chaitanya
Greenhorn

Joined: Aug 20, 2001
Posts: 28
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

Joined: Dec 20, 2001
Posts: 3271
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


SCJP Tipline, etc.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
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.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: not able to run simple java program
 
Similar Threads
Not able to Run in IntelliJ
noclassDefFoundError on maven
NoClassDefFoundError
Configuration
Simple Java Program throwing cannot create process =193 error