Cron can not start Java application as JAR file

S

Stefan Schulz

Hello

I've a problem with cron and Java application.
Env: linux debian
I have installed jdk1.4 as local user in my home catalog.
When I try start simple class that is no problem, but
the problem is when I try start jar application
my script looks like:

While this does not really belong here, check under which user cron runs
the script. It looks as if the jar file somehow is unreachable.
 
G

Grzegorz Wrazen

Hello

I've a problem with cron and Java application.
Env: linux debian
I have installed jdk1.4 as local user in my home catalog.
When I try start simple class that is no problem, but
the problem is when I try start jar application
my script looks like:

#! /bin/bash

PATH=${PATH}:"/home/grzegorz/jdk1.4/bin"
export PATH
java -jar -cp %CLASSHPATH%:/home/grzegorz/cron_test/ Test.jar >
/home/grzegorz/cron_test/log.txt 2>/home/grzegorz/cron_test/errors.txt &

and I got :
Exception in thread "main" java.util.zip.ZipException: No such file or
directory
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:112)
at java.util.jar.JarFile.<init>(JarFile.java:117)
at java.util.jar.JarFile.<init>(JarFile.java:55)

Despite I check out permissions to this catalog, all seems to be fine.
If I start this script manually everything is ok.
What's the problem ?

Regards GW
 
G

Grzegorz Wrazen

While this does not really belong here, check under which user cron runs
the script. It looks as if the jar file somehow is unreachable.

Yes, I agree with You but I dont know what is the reason ?

Jar is generated by Eclipse
 
B

ByteCoder

Grzegorz said:
Yes, I agree with You but I dont know what is the reason ?

Jar is generated by Eclipse

What he means is that the linux user that should run your JAR-file may
not access the directory, so you see an error.
 
L

Lee Fesperman

Grzegorz said:
Hello

I've a problem with cron and Java application.
Env: linux debian
I have installed jdk1.4 as local user in my home catalog.
When I try start simple class that is no problem, but
the problem is when I try start jar application
my script looks like:

#! /bin/bash

PATH=${PATH}:"/home/grzegorz/jdk1.4/bin"
export PATH
java -jar -cp %CLASSHPATH%:/home/grzegorz/cron_test/ Test.jar >
/home/grzegorz/cron_test/log.txt 2>/home/grzegorz/cron_test/errors.txt &

Remove the '-cp' following the -jar toggle and the spaces before Test.jar. -jar must be
followed by the filename (with path) of a jar file. Also note that -cp will be ignored
when using -jar. Check the docs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top