title: Running a jar from shell script
body: <p>I have a jar file named umar.jar in /root/umar/bin directory. I have a shell script file run.sh in same directory. Following is the content of run.sh</p>
  
  <pre><code>#!/bin/bash
  "$JAVA_HOME"/bin/java -jar /root/umar/bin/umar.jar
  </code></pre>
  
  <p>Now when I run the shell script, I get the following error</p>
  
  <pre><code>Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
  </code></pre>
  
  <p>After some googling, I found (as a folk from stackoverflow mentioned) that such errors occur when the Jar was compiled with a later version of the JDK than your JRE.</p>
  
  <p>Now strange thing is, if I run this command directly on shell</p>
  
  <pre><code>java -jar umar.jar
  </code></pre>
  
  <p>it works perfectly fine. If the jar was compiled with a later version of JDK than my JRE, it shouldn't have had run at all even from the shell.</p>
  
  <p>What do you suggest?</p>