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


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

Rep: Reputation: 0
Why cron uses old version java in my VPS (centos 5)??

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?


The exception is like this
Exception in thread "main" java.lang.ClassFormatError: M (unrecognized class file version)
at java.lang.VMClassLoader.defineClass(
Old 07-02-2008, 07:48 PM   #2
LQ Guru
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Linux Mint 17, Debian 8
Posts: 7,863

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
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:

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, 06:49 AM   #3
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.


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-20-2008 12:13 AM
fetchmail - why does CentOS 5 not like my old cron job? mazzo Linux - Server 2 04-23-2007 04:02 PM
Xvnc will not start (CentOS vps) WojtekO Linux - Software 1 11-09-2006 06:51 PM
Where can I download UML VPS or Xen VPS to make a virtual private server? abefroman Linux - Software 3 12-09-2005 11:00 AM
How do I get cron mail to stop forwarding through localhost on CentOS 4? alexmkt Linux - Enterprise 3 11-23-2005 02:27 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:37 PM.

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