Sign in to follow this  
Lucky Ace Card

Please help me with installing Java

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this