javac not recognized..?

0

1

'javac' is not recognized as an internal or external command, operable program or batch file ok i have the jdk1.6.0_21 installed on my pc, but when i try to use the command promt to convert a .java script to a .class script i get the above error msg. can someone help me here please?

user45021

Posted 2010-08-03T18:17:16.013

Reputation: 1

what OS do you use? – akira – 2010-10-11T08:42:14.123

Answers

4

When you install a program (here: javac.exe), you can start that program in two ways:

  • Type the full path: "C:\Program Files\Java 1.X.Y\bin\javac" MyStuff.java (note the quotation marks; they are needed because of the spaces in the path name)
  • Change into the directory, then issue the command: cd "C:\Program Files\Java 1.X.Y\bin\", then javac MyStuff.java (only if the file is in the same directory)

The solution to this is setting the PATH variable. It holds a ; seperated list of folders, where your executable files live. Set it like this for one time change: set PATH="%PATH%;C:\Program Files\Java 1.X.Y\bin". Now you can issue the command javac MyStuff.java in the folder with your source, or from any other folder, without typing the whole path every time.

See other post for setting this permanently. Hope you enjoy coding!

pwn4g3

Posted 2010-08-03T18:17:16.013

Reputation: 195

1

You will need to use the full path of javac or but the bin folder of your JDK in your environment path.

Cannot give any specific details without knowing your platform.

wtaniguchi

Posted 2010-08-03T18:17:16.013

Reputation: 485

windows xp is what i am using would it be goo to change to eclipse to have a compiler, would that be easier or just a waste of time? – user45021 – 2010-08-03T18:35:05.800

you mean to put the bin folder into my java folder? – user45021 – 2010-08-03T18:42:36.897

@plring - it is a good idea to learn how to compile java apps from the commandline, it's always a good idea to know what your ide (eclipse) is doing for you. – Millhouse – 2010-08-03T20:10:11.213

1

The javac executable is probably not in your PATH variable.

Try typing c:\full_path_to_java\bin\javac whatever.class assuming your using windows.

If that works you need to add the java bin to your PATH

To add the java bin directory to your PATH do the following from a command prompt

PATH=%PATH%;c:\Path_to_java\bin

That's assuming that you installed java on the c drive.

To make this permanent add the java\bin path to

System Properties ->  Advanced -> Environment Variable -> System Variables - Path

bryan

Posted 2010-08-03T18:17:16.013

Reputation: 7 848

Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Admin>cd C:\Documents and Settings\Admin\My Documents
java\bin\javac "GrapesSwamptar.java" The system cannot find the path specified.

this is what i get, what am i doing wrong? please help. – user45021 – 2010-08-03T18:38:27.543

hmmm....you have a cd command and a path with a file name in it and a java file to compile. That's just not right. – bryan – 2010-08-03T18:43:33.457

If you're sure you installed java to your My Documents directory you could try the following - 1. change to the directory where GrapesSwamptar.java is located 2. type C:\Documents and Settings\Admin\My Documents\ java\bin\javac GrapesSwamptar.java – bryan – 2010-08-03T18:45:13.570

C:\Documents and Settings\Admin>cd C:\Documents and Settings\Admin\My Documents
java\bin\javac GrapesSwampTar.java The system cannot find the path specified.

C:\Documents and Settings\Admin> oh boy, i know i seem real stupid please help. – user45021 – 2010-08-03T18:49:41.317

would it be easier if i tried to download and use NetBeans IDE to convert a .java script to a .class script (file)?? – user45021 – 2010-08-03T18:56:21.340

The easiest thing is to get your PATH setup correctly. It is likely that NetBeans would not function until you have done this. – bryan – 2010-08-03T20:03:49.600

in your earlier comment you have "C:\Documents and Settings\Admin>cd C:\Documen...." there should be no cd command there – bryan – 2010-08-03T20:05:00.927