# "javac'' and ''java'' won't work (Command Prompt)



## Rachel2507

Hi,
Im learning to programme and I wanted to do some of my work at home.
So i downloaded jdk 5.0 (from sun.com) and jEdit.
I wanted to compile the 'programme' i'd just written with Command Prompt, but whenever i type javac something.java
it says dat javac is not recognized

Ive been told to add the input/output txt files into a specific folder and then go to my computer>properties>advanced>environment....
In the user, i added CLASSPATH
and the other one already had a 'Path' and there i pasted the directory where the input/output tct can be found.
And then i restarted the pc.
But i keep getting the same msg..
And i think the command : java
doesn't work either

I checked around online and they said that i should check in the folder 'bin' if there was a javac.exe and a java.exe if there weren't any, then sth went wrong w/ the intallation.
I re-installed it and there it was.
But Command Prompt still doesn't recognize the command.
Help....


----------



## cristobal03

You have to add the *bin* directory to the *PATH* environment variable. It sounds like somebody pointed you in the right direction but misinformed you somewhat. First let's just see if it's in the path.


Open a *Command Prompt* window (*Start-->Run...*, then type *cmd.exe*).

Type *c:* and press *Enter* to target the system drive. Type *cd\* and press *Enter* to target the system root.

Type *set* and press *Enter*. This will list all the environment variables on your computer.

Scan the list for *PATH=*. The *PATH* environment variable is really a list of files and directories that can be accessed from any other location in your computer. If your java\bin folder is not in the path, any executables in the folder will not be recognized in the path unless you run them directly from that folder.
Post back if your bin library isn't in the path and we'll go from there.

chris.


----------



## Rachel2507

Variable Value
CLASSPATH .;C:\program files\java\ip\io >> in folder io is
input/output.txt

Path %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\SPSSOEM\ODBC42\Drivers\;C:\program files\java\jre1.5.0_05\bin


----------



## cristobal03

Hmmm. It's been a really long time since I've had to configure a Java installation, but it looks like your bin folder is in the Path correctly. I can't remember if Java has to register as a service and be started...also, I can't remember if the binary executables in bin have a different extension than *.exe*. If they do, then their extension needs to be added to the *PATHEXT* environment variable. Check the extensions in the java\bin folder and post those, and also post the PATHEXT envorionment variable.

Hopefully someone who knows/remembers more about configuring Java will bump the thread, but I'll keep tracking things down until I'm out of suggestions.

chris.


----------



## Rachel2507

PATHEXT > .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH


----------



## cristobal03

Well, that all looks okay too. I seem to remember Java registering a service. I don't remember the name though. Try this.


Click *Start-->Settings-->Control Panel-->Administrative Tools-->Services* to open the *Services* window.

On the right-hand side of the *Services* window is a list of services running on your computer sorted alphabetically by name. Scroll down to the J's and, if...er, I guess just post a screenshot.

Something you can do, if you see an obvious Java service, is to look in the *Status* column to see if it's started. If not, right-click the service name and from the context menu select *Properties*.

In the service's *Properties* window, under the *General* tab, set the *Startup type* to *Automatic*, then click *Start*, and *OK* to close the window. This might require a reboot.
Sorry those instructions aren't more explicit, but I'm going off memory here.

chris.


----------



## Rachel2507

Eh j komt niet eens voor....:S


----------



## cristobal03

Sorry Rachel, I think we've gotten past the point where I can help you going off memory. I might've told you to look for the wrong service; since none of them start with "j", it might be something like "Sun Java Virtual Machine," or "JVM" somewhere.

Unfortunately though, I think it's just a problem for which I don't know the solution. With any luck someone smarter than me will post back.

Sorry I couldn't help more 

chris.


----------



## slipkid

Hi Rachael, I am in a similar situation as yourself.No matter what i do my jdk 1.4.2_15 wont be recognized.I have jre1.6 installed and it just keeps refering to that,it's driving me mad!!!So all I can offer is my sympathy but I will keep track and maybe get some tips from your post. Good Luck


----------



## desmin

ok i think i know copy the files 


javac.exe

and 


java.exe


to you windows\system32 and the javac command will work


----------



## wookie2u

des,
(FYI Rach)

Yeah copying java.exe & javac.exe to windows/system(32)? will work but it'll be problematic down the track.

I suspect that you guys are both tripping over Microsofts java implementation (which lives in windows\system32. So, You need to put your JDK/bin () directory in the PATH _before_ windows\system32

in rachaels case that'd be

right click My Computer ~ properties ~ Advanced tab ~ Environment Variables ~ System Variables (NOT User Variables) ~
set the PATH to C:\program files\java\jre1.5.0_05\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\SPSSOEM\ODBC42\Drivers\

so the system will find your new Sun JDK's java.exe and javac.exe before Microsoft's version.

keith.

PS: Your next question is likely be something like:
I keep getting Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
What did I do wrong?

To which I would reply:
Read this: http://www.kevinboone.com/classpath.html
It's worth doing the little exercise presented in the article. It takes maybe an hour, and will save you several days of hair pulling whilst trying to work it out by trial and error.


----------

