Hey, I have installed the jdk in C: directory. I have changed the variables to point to the directory. When I type javac in the Run|command| it works fine. Now when I want to debug something or whatever its called it always comes up with one error found. Where do I save my files to get them to run?
This is what I do in command:
java c:\desktop\FirstProgram.java
and even if the file has no errors it comes up one error found or if it has 100s of errors it still comes up one error found. What do I do?
Make sure you're on the right desktop...
haha, just got to make sure. You'd be surprised how many people I have to deal with in College that do that.
Outside of that, yea, whats the error?
It says:
Exception in thread "main" java.lang.NoClassDefFoundError: c:\desktop\FirstProgram\java
Thats the error. Even if there is more errors then one in program its always say one error found even if there is definetly none.
Theres something wrong with your paths somewhere. Couldnt tell ya which though
| ncwdavid wrote: |
This is what I do in command:
java c:\desktop\FirstProgram.java |
The extension must not be specified. Use this command instead:
| Code: |
| java c:\desktop\FirstProgram |
Quick guide to compiling and running a java program
Make your source code file. The name should be NameOfPublicClass.java
Then, use javac to compile it:
| Code: |
| javac "/path/to/NameOfPublicClass.java" |
(I'm using forward slashes because I'm on Linux. On Windows, use backslashes.)
After compilation, you will get some .class files. Those are the actual java executables.
Run them this way:
| Code: |
| java "/path/to/NameOfClassWithMainFunction" |
Note that even though the file would be called NameOfClassWithMainFunction.class, you should not write the .class in the java command.
If you need an IDE, which you might since it makes things easier, you might wanna check JCreator out...
I used it all the time when I am doing Java few years ago, and its free~