0

I have problems compiling Java programs from command line interfaces (both command prompt and NetBeans terminal).

I added the jdk directory to the PATH system variable but not all commands are recognizable, some commands (in the jdk1.6.0_37\bin folder) are recognized (like: java, javaw, packger)and others I'd have to type the full directory name for it to work (like: jar, javac, javah, javap) (this applies for both cmd and NB).

I don't know why this should be, all of these files are .exe , all are Java Platform SE binary, the only difference I can see is the icon of the files, the ones that work have the Java logo (Coffee Mug) and the rest have the standard .exe logo. Any help would be appreciated. Thanks

Adam Caudill
  • 194
  • 1
  • 11
Aelgawad
  • 174
  • 1
  • 14

2 Answers2

0

You have to add the jdk1.6.0_37\bin directory to the PATH variable. That is where all the commands that you want to run are in. After you add the directory to the PATH variable, open a new command prompt and run those commands again.

Azmi Kamis
  • 781
  • 4
  • 18
  • That's exactly what I did, and in cmd, commands like java work but one like javac is not recognized as internal or external command, operable program or batch file. Unless I write the whole directory – Aelgawad Apr 01 '13 at 00:09
  • Go to the `PATH` system variable again and append `.;` to the end like so `C:\Program Files\Java\jdk1.6.0_37\bin;.;` – Azmi Kamis Apr 01 '13 at 00:32
  • Could you paste what you have in your `PATH` variable if it's not too much? – Azmi Kamis Apr 01 '13 at 03:00
  • Oh yes of course, %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;D:\Program Files\ATI Technologies\ATI.ACE\Core-Static;%systemroot%\System32\WindowsPowerShell\v1.0\;C:\cygwin;C:\Program Files\Microsoft\Web Platform Installer\; C:\Program Files\Java\jdk1.6.0_43\bin\ – Aelgawad Apr 11 '13 at 22:26
0

I'm searched many answers that suggest me to type in cmd:

set path = "%path%;c:program files\java\jdk1.7.0\bin"

but this is WRONG!

the right solution is that you leave "set" and just type

path = %path%;c:program files\java\jdk1.7.0\bin

P/s: of course you have to replace "jdk1.7.0" folder by your current java version folder

eta99
  • 15
  • 3
  • It works temporarly, the commands are recognized as long as I don't close cmd. When I reopen it they are not recognized anymore. Thanks thou. – Aelgawad Apr 11 '13 at 22:35
  • Ok, it just exists temporary, but you can copy this code to notepad (or other editors) then paste to RUN each time you want to run java. Otherwise, you have to follow this guide: http://stackoverflow.com/questions/1672281/environment-variables-for-java-installation to make sure java, javac enabled every time you cmd – eta99 Apr 18 '13 at 05:54
  • The whole thing worked on my XP machine but on this one (Win 8), it is giving me a hard time. – Aelgawad Apr 26 '13 at 12:04