This is my first time at javaranch.com and I am pretty new with java. I installed Java JDK 6 Update 16 under C:ProgramsFiles\Java\ on my computer (windows xp). Of course, I had to try the simple Hello World program. I set up my PATH variable on
System Properties->Advanced->Environment Variables->CLASSPATH=C:\Program Files\Java\jdk1.6.0_16\bin; I then tried to compile hello.java which is
using javac hello.java but it gave an error that says: 'javac' is not recognized as an internal or external command, operable program or batch file. I then tried to move the program inside the bin, compile it and it didn't give me an error. However, I couldn't find the hello.exe program to run. I then tried to break the program (take the quotation mark ") to see if the compiler will complain about it and it sure did give me a compile error on command prompt. I've also tried closing cmd window and even restarted my computer but still no luck. I've tried searching online about and it points to the PATH variable but I think I've set my path correctly.
If anyone ran into this problem or know of any other things I can try, please let me know.
If you managed to get a compiler error when you took the quote mark out, you would appear to have set up your PATH correctly.
The javac command doesn't produce an .exe file. You get a .class file and (if it contains a main method) execute that main method with the command
I suggest next time you open your command line you execute these two commands
Now you have a folder to put all your java work into. Put your "hello World" files into that directory. Now using the cd java instruction whenever you open a command prompt will take you into that folder. You can obviously use a different name, make subfolders, etc. Now try java hello in that folder.
By the way: the convention is for class names to start with a capital letter.
Thanks a bunch for the pointer. I thought about it this morning and did a little lookup on PATH and CLASSPATH. I was setting the wrong environment variable. I needed to set PATH to the write address.
I made a directory using the commands you mentioned on your reponse. I am not totally familiar with command prompt keyword yet but I will look into more of this and use command line to write small program before I switch to gui base compiler (ie eclipse).