LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-02-2008, 06:33 PM   #1
enes1177
LQ Newbie
 
Registered: Jun 2008
Posts: 7

Rep: Reputation: 0
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)
.....
 
Old 07-02-2008, 06:48 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,336

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
Quote:
Originally Posted by enes1177 View Post

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
 
Old 07-03-2008, 05:49 AM   #3
enes1177
LQ Newbie
 
Registered: Jun 2008
Posts: 7

Original Poster
Rep: Reputation: 0
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.
 
  


Reply

Tags
cron, java


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
java -version, bash: java: command not found kirman Programming 4 03-19-2008 11:13 PM
fetchmail - why does CentOS 5 not like my old cron job? mazzo Linux - Server 2 04-23-2007 03:02 PM
Xvnc will not start (CentOS vps) WojtekO Linux - Software 1 11-09-2006 05:51 PM
Where can I download UML VPS or Xen VPS to make a virtual private server? abefroman Linux - Software 3 12-09-2005 10:00 AM
How do I get cron mail to stop forwarding through localhost on CentOS 4? alexmkt Linux - Enterprise 3 11-23-2005 01:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration