Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I am new to UNIX Env.I have a batch file which has the following lines.
#!/bin/sh
PATH=$PATH\:/var/shine/scripts/ListUsersJob ; export PATH
/usr/java/j2sdk1.4.2_10/bin/javac -classpath activation.jar:mail.jar:. ListUsersJob.java
/usr/java/j2sdk1.4.2_10/bin/java -cp activation.jar:jtds-1.2.jar:mail.jar:. ListUsersJob
The above batch job runs well when i try to run it in the same directory (ie.,/var/shine/scripts/ListUsersJob), but when i set this batch job as a cron, it is giving me the
following error when i checked my mail in UNIX env.
mail content _______________________________________________________________
To: jboss@localhost.localdomain
Subject: Cron <> /var/shine/scripts/ListUsersJob/runJob.sh
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/opt/jboss-4.0.3SP1>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=jboss>
X-Cron-Env: <USER=jboss>error: cannot read: ListUsersJob.java
1 error
Exception in thread "main" java.lang.NoClassDefFoundError: ListUsersJob______________________________________________________________________________
The following is my crontab setting[jboss@msapp01s ~]$ crontab -l
05 11 * * * /var/shine/scripts/ListUsersJob/runJob.sh
I would appreciate your help in solving this pr

Export your java variables (JAVAHOME for example) in your script. Most likely, these variables are set in your login shell via the .profile, but they are not set when the job is executed from the crontab.

The current directory for cron is not your directory, so put this line in runJob.sh before you call javac or java:
cd /var/shine/scripts/ListUsersJob

Ken:
The java error indicates the process is not finding the java class files. It is an environment issue, not a PATH issue. If JAVAHOME is not set, the " Exception in thread "main" java.lang.NoClassDefFoundError: ListUsersJob" error occurs. There are also other java variables that might need to be set. I'll bet that they are set in his .profile, which is why his process executes from a command line.

![]() |
VMware Linux fedora 5
|
Printing in Linux
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |