简体   繁体   中英

crontab error running exe jar

I'm trying to run a simple crontab scheduler using:

*/15 * * * * /usr/bin/java java -jar /tnpm/tnpm_pm_test.jar

But I'm getting this error:

Exception in thread "main" java.lang.NoClassDefFoundError: java
Caused by: java.lang.ClassNotFoundException: java
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: java. Program will exit.

I tried doing "whereis java" in my unix window and the java path is declared properly:

java: /usr/bin/java /etc/java /usr/lib/java /usr/share/java /usr/share/man/man1/java.1.gz

Anyone has any idea? is it privilege or user issue? or my crontab command is wwrong? or am I pointing it to the wrong java path? thanks...

EDIT:

in addition using "which java" points to /usr/bin/java and the complete path of my exe jar is under "/home/user1/tnpm/tnpm_pm_test.jar".

You should have java in your PATH, and you should find the dir of the java libs and put its path in your LD_LIBRARY_PATH. Hopefully that will help. I have seen /usr/bin/java -jar and not /usr/bin/java java -jar. You must also include the complete path for the jar file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM