10

I downloaded and installed JDK from Java SE Development Kit 7 Downloads in "c:\jdk.1.7.0", set variable path to "c:\jdk.1.7.0", but using command for example:

jar xvf ..\src.zip

Gives me this error:

'jar' is not recognized as an internal or external command,
operable program or batch file.

I'm reading Core Java volume 1 (9th edition). So here it stated to run firstly command:

javac -version

Then I got that same error. And in bin directory there were no javac.exe too, but I found java.exe and it worked. So does jar.exe is also changed to some another name or it somewhere else? It seems strange that this book is released this year and even names of files do not match in newest version or am I missing something here?..

P.S. I'm using windows 7 64 bit.

using command:

echo %PATH%

retuns:

%JAVA_HOME%\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%CommonPr
ogramFiles%\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Wind
ows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\I
ntel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Fi
les (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2
.0\bin\x64;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program File
s\Common Files\Microsoft Shared\Windows Live;C:\Program Files\Intel\WiFi\bin\;C:
\Program Files\Common Files\Intel\WirelessCommon\

%JAVA_HOME% is set to C:\jdk1.7.0

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
Andrius
  • 19,658
  • 37
  • 143
  • 243
  • 7
    Surely you know how to search in your OS. If you installed the Java JDK through the installer, [start] -> type "jar.exe", and there it is. – Mike 'Pomax' Kamermans Sep 12 '13 at 16:16
  • please check http://stackoverflow.com/questions/7709041/javac-is-not-recognized-as-an-internal-or-external-command-operable-program-or you will get the solution – upog Sep 12 '13 at 16:18
  • 1
    Andrius, the directory you need to add to your PATH environment variable is not "C:\jdk.1.7.0", but "C:\jdk.1.7.0\bin", where "java.exe", "javac.exe", "jar.exe" and the rest of the executables are. –  Sep 12 '13 at 16:26
  • @AndreiJuan I posted `%JAVA_HOME%\bin` to be added in the PATH environment variable – Luiggi Mendoza Sep 12 '13 at 16:31
  • I just installed JDK 8, and it contains, neither %java_home%/bin/jar nor %java_home%/src.zip so, this question pertains to setting up a java programming environment, which is hardly off topic, but is, sort of goofy ganging up on beginners. oracle? – Ryan Zoerner Oct 11 '16 at 00:32

4 Answers4

6

I just installed that same download on Windows 7 64-bit and I have C:\Program Files\Java\jdk1.7.0_40\bin\jar.exe so you probably do also.

I did notice you installed to a non-standard location, and that the installer gives you two chances to change where it installs.

The first installer window is installing the JDK. Then a second window comes up and that installs the JRE.

You probably installed the JDK to one place and the JRE to another place. The JDK will have jar.exe, javac.exe, and java.exe inside its bin folder. The JRE will only have java.exe there.

Therefore you should find where you installed the JDK. The default place is C:\Program Files\Java\jdk1.7.0_40 so it is there unless you changed it.

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
2

It sounds like you have the JRE not the JDK. Check that you installed the right one, then check that you are looking in the right directory on your pc. You should have both.

Next note that the Path should also include the bin folder.

Ken
  • 654
  • 8
  • 18
  • My path has bin folder. So link I provided is not jdk?.. – Andrius Sep 12 '13 at 16:16
  • The link sends me to a page that says "Sorry, please accept the license terms" so I cannot download it. But it does look like it is a JDK just according to the file's name. Typically if you have java.exe and not javac.exe then you have installed a JRE. A JDK will install javac.exe and jar.exe – Kevin Panko Sep 12 '13 at 16:21
  • If theres is no javac.exe in bin folder, you have installed something other than the package in your question. – Gyro Gearless Sep 12 '13 at 16:22
  • @KevinPanko that's right, you must accept the license terms before downloading the JDK distribution. I'll fix link in OP's question. – Luiggi Mendoza Sep 12 '13 at 16:24
  • I would be more inclined to suspect your PATH variables are incorrect than the download. Try running "echo %PATH%" in a cmd window and ensure that it contains somewhere "c:\jdk.1.7.0_40\bin" – Ken Sep 12 '13 at 16:29
1

It is located in the bin folder. You should link to c:\jdk.1.7.0\bin

Quillion
  • 6,346
  • 11
  • 60
  • 97
0

Looks like you have to set the JAVA_HOME as part of the PATH variable in your Windows system environment. The steps to define the JAVA_HOME variable is here: How to set java_home on Windows 7?, the only changes for this would be using the c:\jdk.1.7.0 (the path of your JDK installation) instead of C:\Program Files\Java\jre6.

After doing this, edit the PATH variable to look like this

%JAVA_HOME%\bin; rest of your current PATH variable value

To verify if the changes were done correctly, open a cmd and write

javac -version

You should get the exact version. In my case:

javac 1.7.0_40

And in bin directory there were no javac.exe too, but I found java.exe and it worked.

Seems that you haven't installed the JDK in the path you think. Look for the real JDK path installation and point the JAVA_HOME system environment variable value to that folder.

Community
  • 1
  • 1
Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
  • Still get message - 'javac' is not recognized as an internal or external command, operable program or batch file. – Andrius Sep 12 '13 at 16:27
  • @Andrius paths are fixed. In order that the cmd can take the changes done in system environment variables, you must close it and open it after doing the changes. – Luiggi Mendoza Sep 12 '13 at 16:29
  • Don't get it what was wrong. Now I reinstalled JDK, and I can see both javac.exe and jar.exe in bin. Anyway thank you everyone. – Andrius Sep 12 '13 at 16:43
  • My answer explains what you did wrong. – Kevin Panko Sep 12 '13 at 16:45