How to set the classpath in cron job
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   karthik_kamaraj
Posted On:   Friday, April 8, 2005 12:03 AM


Hi,
I have to run a shell script from as a cron job.The shell script contains the java application.I have set the classpath in the shell script itself ,but still the cron job unable to find the classpath.Please tell me how to set the classpath in crontab.

Re: How to set the classpath in cron job

Posted By:   Ravi_Kesariraman  
Posted On:   Friday, April 8, 2005 02:05 AM


I hope the code snippet below will help you:



#!/bin/sh

cd $HOME/scriptdirectory

JAVA_HOME=/usr/jdk
MYLIB=/home/myhome/jars

CP=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib
CP=$CP:$MYLIB/lib/activation.jar
CP=$CP:$MYLIB/lib/mail.jar
CP=$CP:$MYLIB/lib/myapplication.jar
CP=$CP:.

$JAVA_HOME/bin/java -classpath $CP com.xxx.yyy.MyServer > log.txt 2>&1



1. myapplication.jar : JAR file containing my application related classes

2. com.xxx.yyy.MyServer : Application that need to be run from the script

3. log.txt is a log file to capture the output

4. $HOME/scriptdirectory : Directory where your script resides



About | Sitemap | Contact