Ernest Friedman-Hill wrote:Tha "garbage" is the contents of that class file. I don't know precisely what you typed to see that, but the way to run a Java class file is to type "java" followed by the name of the class -- not the path to the class file, or the name of the class file. So cd into the directory "C:\Users\name\Documents\My JAVA SE" and type "java MyFirstClass".
Now go and read this article: HowToSetTheClasspath .
And finally, try running from some other directory using the -cp switch:
java -cp "C:\Users\name\Documents\My JAVA SE" MyFirstApp
Most of the time this last way of doing things is what you'll really use in the scripts that run your programs.
David Newton wrote:That's because you're executing from within the directory where javac is located, not where the Java source code file is located...
David Newton wrote:You'll need to put spaces around path names with spaces in them.
I don't understand why you haven't just tried it, or just typed in the complete path to the executable to see if it actually works--it'd be much, much faster than waiting for someone to help you here, no? Recall that even Windows has path completion via the TAB key.
And again: read up on the OS you're using; there are hundreds of tutorials, and Microsoft's own documentation, that tell you how to work in the environment you're working in. Why waste time not knowing how things work?
David Newton wrote:In the path, towards the front. You might want to get acquainted with how your OS works before going too much further--it will reap great dividends and make your life substantially easier.
Assuming your JDK is in c:\jdk1.6:If it's somewhere else, please use that path instead of the placeholder I used.
David Newton wrote:
I wrote:Is there a JDK "bin" directory on your path? If not, you need to make it so there is (or, I suppose, you could type in the full path, but that's really irritating).
Roger F. Gay wrote:Check java sdk setup instructions for setting the JAVA_HOME environment variable. If you're using Windows, you create the environment variable by clicking on System in the Control Panel -> Advance System Settings -> Environment Variables (button). If JAVA_HOME is set correctly, then javac will be recognized everywhere.
Christophe Verré wrote:
I guess I could edit the variable PATH variable within the "Sys variables" group
Yes. You can also set JAVA_HOME there.
1) JAVA_HOME = C:\Program Files\Java\jdk1.5.0_22
You mean I create a new variable in the "System Variable" group, name it JAVA_Home and the variable value to be C:\Program Files\Java\jdk1.5.0_22?
2)PATH = "%JAVA_HOME%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\"
You mean I edit the Path variable within the "System Variable" group, add "%JAVA_HOME%\bin;" right before %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\"?
Thanks.
Joanne Neal wrote:And unless you have some specific reason for using Java 1.5 it's probably best to use the latest version which is 1.6.
David Newton wrote:(I'm not sure what word "carpet" is supposed to be, but I'm pretty sure it's not "carpet" :)