Please help me with installing Java
Man, I feel like an idiot.
I must have installed Java incorrectly. I'm just starting to learn it, so I wrote the HelloWorld.java program. I went into command prompt, did
javac HelloWorld.java
And it created the class file.
However, if I do:
java HelloWorld
in command prompt, I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
Any help on what I did wrong? Thanks a bunch... I'm learning from some outdated book.
Is the class name EXACTLY the same as the output class name, including the caps of the characters?
Dave
Dave
Yes.
HelloWorld
That's it. Caps and all.
*EDIT* Ah, I think I finally got it! I finally managed to figure out how to set my ClassPath.
HelloWorld
That's it. Caps and all.
*EDIT* Ah, I think I finally got it! I finally managed to figure out how to set my ClassPath.
On a side note: that slightly annoying message can pop up in another situation -- say you have created a moderately large project -- and you use packages. If you navigate to your source folder and compile your code...then try to run the app, it will often fall over with the same message. Reason for this is because packages created by applications (...eclipse, etc) will resolve to a directory structure...so, if you move up a level (cd ..) and try java presentWorkingDirectory/mainclass (or presentWorkingDirectory.mainclass) it will work without a fuss...still, it's a minor issue though it bugged me when it came up :)
Hence why I now create a batch file to run my java programs ;)
~Shiny.
Hence why I now create a batch file to run my java programs ;)
~Shiny.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement