First, you must make sure that each class is in its own file.
Then, make sure that each file has the same name as the class contained
in it.
Then, compile all the files.
Then use "java" to run the file with "main" in it.
For example, below you quoted the error message:
"Exception in thread "main" java.lang.NoClassDefFoundError: AppName"
In this example java was looking for a file named AppName.class
Apparently you either hadn't named the java file the EXACT same name as
the class that contained your main method.
However, now that your "class AppName" (which is the one that contain
"main") is in the file "AppName.java", and you compiled it like "javac
AppName.java", you will now have a file called "AppName.class" which can
be run like "java AppName".
I hope that wasn't too convoluted of an answer. But that was usually
the problem I had when I ran into that compiler error. Hope this
helped.
-David C.
Legless wrote:
>
> When running a compiled java program i get the message:
> Exception in thread "main" java.lang.NoClassDefFoundError: AppName
> What is wrong?
> i can't even run the HelloWorldApp example!
> I'm using win32.
"David Cleaver" <dav...@ou.edu> wrote in message
news:392F3295...@ou.edu...
> A couple of possiblities...
> (I'm pretty sure this is right, but if someone tells you that I'm wrong,
> then hopefully they'll give a better answer... :)
>
> First, you must make sure that each class is in its own file.
> Then, make sure that each file has the same name as the class contained
> in it.
> Then, compile all the files.
> Then use "java" to run the file with "main" in it.
>
> For example, below you quoted the error message:
> "Exception in thread "main" java.lang.NoClassDefFoundError: AppName"
> In this example java was looking for a file named AppName.class
> Apparently you either hadn't named the java file the EXACT same name as
> the class that contained your main method.
>
> However, now that your "class AppName" (which is the one that contain
> "main") is in the file "AppName.java", and you compiled it like "javac
> AppName.java", you will now have a file called "AppName.class" which can
> be run like "java AppName".
>
> I hope that wasn't too convoluted of an answer. But that was usually
> the problem I had when I ran into that compiler error. Hope this
> helped.
>
> -David C.
>
> Legless wrote:
> >
After this you will need to reboot in order for the changes to take
place. Then, hopefully, all should be well and you can run your
program. You won't even have to re-compile. Good luck.
-David C.