noClassdeffounderror with external jar when running code from a different location
<p>I'm learning Java and was trying to test my code on another machine but am running to the above error.  I've looked at youtube videos, read forums(and SO) but still can't get this to work.  </p>

<p>I basically wrote some code on my mac using eclipse that referenced an external jar file.  I have that jar in my lib folder and have added it to my build path in Eclipse via right-click "Build Path -> Add to Build Path".  The code works fine on my laptop.</p>

<p>But when I try to run it from a linux command line, I get the above error.  I am taking the code from eclipse and copying it to a file(first_try.java) and then run this commands:</p>

<pre><code>CLASSPATH=./jedis-2.0.0.jar;export CLASSPATH 
javac first_try.java 
java -classpath . first_try
</code></pre>

<p>but then I get the error: <code>Exception in thread "main" java.lang.NoClassDefFoundError: redis/clients/jedis/Jedis</code>   I downloaded the program via wget and checked permissions and tried different variations. There was a similar question I found(out of the many related ones) that had a similar context as mine but it worked for the user to just type java filename (which is not working for me)</p>

<p>I am learning a bit of java code but have never been successful at running external jars.  I'm wondering what I'm doing wrong and what I can do to permanently fix it(ideally I want to write code locally and then copy it and test it on another machine like this)?</p>

<p>Or is there a better way to deploy code that depends on third party jars to other systems?</p>
