I need to extract the contents of the Jar in to a specific location. When I run the below command to extract jar, it works correctly.

jar -xf location/ex.jar

The same command I placed inside a script(.sh/.ksh). When I run the script, I get the below error:

 jar:  not found.

Both the user are same from which I run the script/command.
I am using AIX server.

  • It looks like your PATH environment variable is not initialized the same way in your terminal and in your script. Which might be normal actually. First, ensure that you are using the same shell (type echo $0 in your terminal) and set your script header (for instance #!/bin/bash). Then, check your environment initialization files and find precise information about their loading order to be sure of what is done with your PATH variable. – maxime.bochon Oct 5 '15 at 12:00
  • @maxime.bochon : echo $0 in my terminal gives output as "-ksh". can u please suggest what would be the script headder for my script. I am new t unix scripting and I am not sure of these. – codeFreak Oct 6 '15 at 10:08
  • You could find explanation on wikipedia here. Maybe kshis more standard on AIX, but if it's only for launching a Java application, it does not really matter. Use the which command to get the path to the binary. For instance, which ksh may display /bin/ksh. – maxime.bochon Oct 7 '15 at 12:30

jar is not found is the message you get. Meaning it can't find jar.

Do a

whereis jar

and use that full path in your script

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.