-
Complier not working
Hi,
As I am just starting out I have gone for the ubiquitous 'Hello World' programe as per the tutorials on line. I have downloaded the JDK programe and installed it but when I come to compile I get the following message:
'javac' is not recognised as an internal or external command, operable program or batch file.
Is there anything obvious I am doing wrong?
Thanks,
Ben
-
Re: Complier not working
You're asking the command-line to look for javac in locations it can't find it, and the command-line is telling you that.
There are a few ways to fix this (assuming you're using windows, linux is a bit different but not by much):
1. Use the full path to java. This is a bit laborious, but works. For example:
> "C:\Program Files\Java\jdk\bin\javac" helloworld
2. Set your PATH environment variable to contain the path to the jdk bin folder. There are a few ways to do this, a quick google search should help you figure out how to do this. You'll have to logoff/restart to make sure that Windows updates the PATH variable. You can now call javac like this:
> javac helloworld
3. Navigate to the jdk bin folder. Now you can call javac without it's path, but you'll need to pass in the path to the java source code.
> javac -sourcepath "C:\JavaSources\helloworld\" helloworld
-
Re: Complier not working
Cool, I set the path in control panel so it worked and I got my 'Hello World' to compile and run.
Now all I need to do is master the language. Are there any good beginner resources that you guys can suggest?
Thanks,
Ben
-
Re: Complier not working
There are Sun/Oracle's Java tutorials. However, while these tutorials cover a lot, they're a little difficult to follow for beginners. Once you've got the Java syntax and lingo down, though, you should be able to whip through them and start writing your own programs in no time.
The best way I found to learn Java was to take a class and then reinforce what I learned in class with other sources (such as here, the tutorials page I suggested, talking with the professor/fellow classmates, etc.).