The file path is C:\JavaSrc\MooseGreetings.java. Anyway, I try to complie it as instructed by typing C:\JavaSrc> javac MooseGreetings.java and I get the message "'javac' is not recoginsed as an internal or external operable program or batch file". I then try to do it a different way by typing "java" instead of "javac" like this: C:\JavaSrc>java MooseGreetings.java and I get the message "Exeption in thread "main" java.lang.NoClassDefFoundError: MooseGreetings/java Caused by: java.lang.ClassNotFoundExcetpion: MooseGreeting.java at java.net.URLClassLoader$1.run<unknown Source> at .. " and it goes on. Does anyone know what I am doing wrong? This seems like it should be pretty simple..
So you need to install a java development environment (JDE) instead of a java runtime environment (JRE).
'javac' is the right command to compile your source code (in your .java file); that creates a file with the same filename but a .class extension.
'java' is the right command to run your java file.
For historical reasons (I guess), your command should include the file extension on the compile step, but not not on the run step:
Benjamin Thvedt wrote:Thanks for the replies and for clearing up the difference between java and javac. The program works, and I think the actual cause of the problem was that I didn't restart the command window after setting the path to the jdk bin in the control panel. That's my best guess anyway, I'm not 100 percent sure, but it works now. Oh, and thanks for clearing up the difference between the jde and jre.
Your guess is correct; a setting made in Control Panel doesn't have any effect on the environment variables in windows that are already open.
Glad you got it working.