jar
is part of the JDK. If you installed the JDK correctly, you should have it. As far as I'm concerned, the path to jar
is /usr/lib/jvm/java-7-openjdk-amd64/bin/jar
. The version and architecture are the main variables.
In most cases, the binary should be made available to your shell's PATH
through a few symlinks. For instance, on my Ubuntu machine, jar
is found at /usr/bin/jar
, which is itself a symlink to /etc/alternatives/jar
(another symlink). The final destination is /usr/lib/jvm/java-7-openjdk-amd64/bin/jar
.
It is possible that you may not have these links correctly set up (especially if you don't use the update-alternatives
mechanism), which might make your shell unable to find the jar
executable. The first step to solve this is to locate it. Have a look at the various paths I've given earlier, and try to locate it.
Note: as a last resort, you can use the following find
command to have it looked up system-wide:
$ find / -type f -name "jar"
Once you have found it, make sure the directory in which it lies is within your PATH
.
For instance, let's assume you don't want to create links. If you were to add the /usr/lib/jvm/java-7-openjdk-amd64/bin
directory to your PATH
, you'd add the following to your ~/.bashrc
file:
export PATH="$PATH:/usr/lib/jvm/java-7-openjdk-amd64/bin"
After re-sourcing the file, or reopening your terminal, you should be able to run jar
. Now, if you don't want to use that trick, and prefer to use a symlink, you could do something like...
$ sudo ln -s /usr/lib/jvm/java-7-openjdk-amd64/bin/jar /usr/bin/jar
Of course, you'd have to make sure that /usr/bin
is within your PATH
, or you would just end up with the same problem all over again.