1

I have a shell script file (run.sh) that contains the following:

#!/bin/bash
%JAVA_HOME%/bin/java -jar umar.jar

when i try to run it (./run.sh), it gives me following: umar/bin/run.sh: line 1: fg: no job control

However if I run same command directly on shell, it works perfectly.

What's wrong with the script file?

Thanks

1
  • 1
    have you put #!/bin/bash as the first line of the script? Commented Oct 20, 2009 at 1:34

3 Answers 3

9

%foo% is not how you do command substitution in a bourne/BASH shell script. I assume you're running this from a Windows command line, which is why it works when you run it directly. Try using proper bourne syntax:

${JAVA_HOME}/bin/java -jar umar.jar
Sign up to request clarification or add additional context in comments.

9 Comments

Don't forget to protect the variable against spaces: "$JAVA_HOME"/bin/java.
Thank Paul. I made the changes suggested by you. Atleast now I am not getting the "fg: no job control" message. But now it is giving me this error: "Unable to access jarfile umar.jar" even I have set all permissions true: "chmod 777 umar.jar". Strange fact is that it works perfectly if I run the jar directly from shell.
Is umar.jar in the current directory?
yes it is in current directory... This issue is also resolved by giving full path of jar file ... Now strangely I am getting a third type of error: "Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file" I guess I should start a new thread for this.
Umar, that message is usually because it was compiled with a later version of the JDK than your JRE.
|
2

Try turning on monitor mode

set -m

Comments

2

%JAVA_HOME% will substitute a Windows environment variable and is appropriate in a .bat file.

Try the following shell script which should work on most UNIX like systems.

#!/bin/bash
$JAVA_HOME/bin/java -jar umar.jar

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.