Starting the java programming side of my Computer Science degree in October and I was looking at geting a head start. Ive downloaded the Java Development Kit as suggested in 'the Learn Java through a little hard work in the JavaRanch Cattle Drive' section of your website but I cant get thet Hello World program to run in my DOS command prompt. It says it doesnt recognise the JAVAC command.
HelloWorld.java:1: error while writing Hello World: HelloWorld.class <Access is denied>
public class HelloWorld
Thanks for your help
Joined: Sep 01, 2010
Thanks for that thread on changing the PATH whats the difference between the PATH and CLASSPATH and which directory do I need to put in? C:\Program Files\Java\jdk1.6.0_21\bin this one or the one suggested on this website?
I they both just pointing the command pompt to my classes?
PATH is what Windows uses to find programs to run. CLASSPATH is what Java uses to find *.class files to run. It's best to leave CLASSPATH not set to anything. If you don't set it, Java will look in the current directory for class files.
Don't put your source code or compiled classes in C:\Program Files\Java\jdk1.6.0_21\bin. You're not supposed to put anything in that directory. Just create a C:\Projects directory or something like that, and put your own stuff in there.
So, for example my HelloWorld program is the c:\Projects folder and I want to compile and run it. As long as my PATH is set correctly it should be no problem to go to c:\Projects in DOS and run the compile command JAVAC? Also, am I setting the path to C:\Program Files\Java\jdk1.6.0_21\bin or the one suggested on the website?
Joined: Sep 01, 2010
Got it, thanks for your help I added this C:\Program Files\Java\jdk1.6.0_21\bin to my PATH. I ran the file as you suggested from c:\Projects and it ran a treat. Thanks for all your help.
Go checkout the library at your college and see if they have "Head first java", if not try and pickup a second hand copy off ebay/amazon. Read through that and you'll be better placed than a lot in your class!