Sunny Sunny - 7 months ago 49
Bash Question

Crontab java.lang.ClassNotFoundException with a jar file

$JAVA_HOME/Contents/Home/bin/java -cp $CLASSPATH ".:/Users/sunny/Downloads/sqlite-jdbc-" sample.Main
exit 0

Sqlite jar file is in

Compiled java class file is in

And I've set the cron job to be schedule at every 1 minute. Java class is getting exucuted but I am getting
java.lang.ClassNotFoundException: org.sqlite.JDBC

Same command which is in script is working in terminal.

My question is how can I add jar file properly to be executed from shell script.


Seems there is a space in between your $CLASS PATH and ".:/Users/sunny/Downloads/sqlite-jdbc-" and missing a colon(:).

Please try with following with export:

export CLASSPATH=.:/Users/sunny/CronTest/out/production/CronTest:/Users/sunny/Downloads/sqlite-jdbc-

and call java command with -cp $CLASSPATH.

If it still not work, please try with -cp directly:

$JAVA_HOME/Contents/Home/bin/java -cp ".:/Users/sunny/CronTest/out/production/CronTest:/Users/sunny/Downloads/sqlite-jdbc-" sample.Main