LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Why cron uses old version java in my VPS (centos 5)?? (http://www.linuxquestions.org/questions/linux-server-73/why-cron-uses-old-version-java-in-my-vps-centos-5-a-653194/)

enes1177 07-02-2008 06:33 PM

Why cron uses old version java in my VPS (centos 5)??
 
Hello;
I have a VPS server working on Centos 5.

I have a Java program and I can run it successfully by ssh.
However when I try to schedule this Java program by cron, it gives an error which typically occurs when an older Java version is used.

How I can configure cron to use the correct Java library? Or is there anything that I am missing?

Thanks;


The exception is like this
Exception in thread "main" java.lang.ClassFormatError: M (unrecognized class file version)
at java.lang.VMClassLoader.defineClass(libgcj.so.7rh)
.....

jailbait 07-02-2008 06:48 PM

Quote:

Originally Posted by enes1177 (Post 3202181)

How I can configure cron to use the correct Java library?

Cron uses its own PATH which is probably different than the PATH use by root or user. You might need to set up a PATH in the script run by cron which points to the correct version of Java. Something similar to this should be the first two statements in the script that cron executes:

PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
export PATH

To find the correct files to include in your cron PATH issue this command:

echo $PATH

as a user or root which accesses the correct version of Java.

---------------------
Steve Stites

enes1177 07-03-2008 05:49 AM

Thanks, the problem is fixed
 
Thanks a lot, Steve. It works now.

Previously I tried to modify the PATH parameter defined in /etc/crontab, I wonder why it did not work.

Anyway, defining it in .sh file worked, thanks.


All times are GMT -5. The time now is 01:25 AM.