Computer Science Canada

Compiling Java

Author:  asd5520 [ Sat Sep 12, 2009 1:44 pm ]
Post subject:  Compiling Java

Hi, im a beginner to java. I was reading the post in the tutorial section "An introduction to Java". I couldn't compile my HelloWorld.java in command prompt. I followed the steps but when i type javac HelloWorld. it says javac is not recognized as internal or external program. How can i fix it?

Author:  wtd [ Sat Sep 12, 2009 2:49 pm ]
Post subject:  RE:Compiling Java

You need to fix your PATH environment variable.

Author:  Insectoid [ Mon Sep 14, 2009 10:57 am ]
Post subject:  RE:Compiling Java

Wtd, sometimes you need to push in the right direction a little harder.

So, right now, your computer has no idea what 'javac' is. You need to tell it via the PATH environment variable where javac is, so that it can let javac take over the terminal. Sort of.

So, somewhere in Windows is a list of environment variables, and you need to add 'javac' and the path where you installed the compiler to the list.

Or something like that.

Author:  andrew. [ Mon Sep 14, 2009 3:17 pm ]
Post subject:  RE:Compiling Java

Here is how to do it (at least on XP):

1. Right click on "My Computer" on your desktop and choose 'Properties'
2. Choose Advanced tab.
3. Click on Environment Variables.
4. Find the PATH variable and 'Edit' it's value to include:
C:/Program Files/Java/jdk1.6.0_05/bin

You may have to change the path depending on the version you installed and where you installed it.

Author:  wtd [ Mon Sep 14, 2009 10:53 pm ]
Post subject:  Re: RE:Compiling Java

insectoid @ Mon Sep 14, 2009 11:57 pm wrote:
Wtd, sometimes you need to push in the right direction a little harder.

So, right now, your computer has no idea what 'javac' is. You need to tell it via the PATH environment variable where javac is, so that it can let javac take over the terminal. Sort of.

So, somewhere in Windows is a list of environment variables, and you need to add 'javac' and the path where you installed the compiler to the list.

Or something like that.


I've gotten a bit jaded by some experiences where I did a lot of hand-holding and then had people just give up as soon as they ran into a problem I didn't have a step-by-step answer to.

If asd5520 wants to solve this problem, he need only google for "path environment variable" and he'd have the answer. Heck, if he'd googled the original message, he'd probably have immediately gotten a step-by-step answer.


: