...making Linux just a little more fun!
Mudassar Khan [mudassar at jumpgames.co.in]
[[[ I've retitled this thread from its original "query" title to something more descriptive. -- Kat ]]]
Hi, Can I run java class file using cron. If yes. then help me. Regards, Mudassar Khan
Thomas Adam [thomas.adam22 at gmail.com]
Hello --
On 14/11/2007, Mudassar Khan <[email protected]> wrote:
> > Hi, > > Can I run java class file using cron.
Again what the HTML. Stop it.
Yes you can run a java class file with cron.
java somefileAssumes you have $JAVA_HOME set correctly which you will need to do within the crontab file due to how cron clobbers the environment it runs under.
-- Thomas Adam
Mudassar Khan [mudassar at jumpgames.co.in]
Hi Thomas, I m not able to run java class file in cron.
I have set my crontab like this..
* * * * * java /opt/javafiles/Movefile >> /tmp/t.logbut I got following error.
Exception in thread "main" java.lang.NoClassDefFoundError: .opt.javafiles.Movefile at gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.5.0.0) at _Jv_ThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.5.0.0) at _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/libgcj.so.5.0.0) at __gcj_personality_v0 (/root/java.version=1.4.2) at __libc_start_main (/lib/tls/libc-2.3.4.so) at _Jv_RegisterClasses (/root/java.version=1.4.2)Can you help me..?
Regards, Mudassar Khan
Thomas Adam [thomas.adam22 at gmail.com]
Hello --
Do you somehow not understand how email works? You should reply to the thread you started, and not create a new one, especially since your reply has relevance.
[[[ Thankfully, the thread was not renamed, just not replied to properly, so it wasn't hard to reconcile. Still, thanks for pointing that out, Thomas! -- Kat ]]]
On 15/11/2007, Mudassar Khan <[email protected]> wrote:
> Hi Thomas, > I m not able to run java class file in cron. > > I have set my crontab like this.. > > * * * * * java /opt/javafiles/Movefile >> /tmp/t.log
This is bad. This will continually run the specified program, not to mention potentially fill up /tmp very quickly if it contains any data.
> but I got following error. > > Exception in thread "main" java.lang.NoClassDefFoundError: > .opt.javafiles.Movefile > at gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.5.0.0)
Install the JRE from Sun, and not use the GNU stuff. My reply to you from before about JAVA_HOME also applies here.
-- Thomas Adam
Trevor Pearson [trevor at haven.demon.co.uk]
Thomas Adam wrote:
> Hello -- > > Do you somehow not understand how email works? You should reply to > the thread you started, and not create a new one, especially since you > reply has relevance. > > On 15/11/2007, Mudassar Khan <[email protected]> wrote: > >> Hi Thomas, >> I m not able to run java class file in cron. >> >> I have set my crontab like this.. >> >> * * * * * java /opt/javafiles/Movefile >> /tmp/t.log >> > > This is bad. This will continually run the specified program, not to > mention potentially fill up /tmp very quickly if it contains any data.
This is also going to fail because java (sun java, I haven't tested gnu) does not allow a path to be specified like this only a java class name. you need to run a command like this
java -cp /opt/javafiles movefilesusing the 'classpath' switch to specify a path if the class file is in a directory that is not in your CLASSPATH environment variable.
>> but I got following error. >> >> Exception in thread "main" java.lang.NoClassDefFoundError: >> .opt.javafiles.Movefile >> at gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.5.0.0) >
This error translates as 'didn't find the file' since java has helpfully searched your current directory and CLASSPATH directories for a file called '.opt.javafiles.Movefile.class' . This behaviour must have seemed a sensible idea to someone at sun