Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Scheduling a java program on Windows

Reply
Thread Tools

Scheduling a java program on Windows

 
 
Mike
Guest
Posts: n/a
 
      03-16-2005
How can I execute a Java program using Windows (XP) Task Scheduler?

Do I have to place a batch program wrapper on it?


 
Reply With Quote
 
 
 
 
Malte
Guest
Posts: n/a
 
      03-16-2005
Mike wrote:
> How can I execute a Java program using Windows (XP) Task Scheduler?
>
> Do I have to place a batch program wrapper on it?
>
>

I am running quite a few on a Windows NT server. I schedule cmd files
that wrap calls to java (java -jar ....)
 
Reply With Quote
 
 
 
 
David McDivitt
Guest
Posts: n/a
 
      03-16-2005
If you have the classpath already set up you can do everything on the
command line in your shortcut. Otherwise you must use a batch file to set
environment variables.

>Subject: Scheduling a java program on Windows
>Date: Wed, 16 Mar 2005 18:58:18 GMT
>
>How can I execute a Java program using Windows (XP) Task Scheduler?
>
>Do I have to place a batch program wrapper on it?


 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      03-16-2005


Thanks Malte.

Could you or some other kind soul please point me to sample code on
the Web to do the wrapper?

I'm a Unix type.



On Wed, 16 Mar 2005 20:25:15 +0100, Malte
<(E-Mail Removed)> wrote:

>Mike wrote:
>> How can I execute a Java program using Windows (XP) Task Scheduler?
>>
>> Do I have to place a batch program wrapper on it?
>>
>>

>I am running quite a few on a Windows NT server. I schedule cmd files
>that wrap calls to java (java -jar ....)


 
Reply With Quote
 
Malte
Guest
Posts: n/a
 
      03-16-2005
Mike wrote:
> Thanks Malte.
>
> Could you or some other kind soul please point me to sample code on
> the Web to do the wrapper?
>
> I'm a Unix type.
>


The below is a windows cmd file (named ldapsync.cmd). What it does isn't
too interesting, it sucks all entries from Active Directory using LDAP
calls and copies them into Oracle LDAP. The cmd file could be much
prettier, but it should get you started. It begins by setting the
envionment, much as you would do it on unix. It then runs the first
program, LDAPsync.jar.
The cmd file then sets up the environment to run the second jar file,
adg2oidg.jar, then exits. I could have put the commands in two separate
cmd files, but since they have to run both of them, and in the order
specified, it was easier to just put them both in the same file.
Bascially, this is as simple as a shell script on unix. Windows cmd
files are a bit more flexible these days than they used to be, but can't
hold a candle to bash, of course.

As it happens, the example below shows two different ways of calling
Java from within the file. The first program is called using only
variables, the second program explicitly sets the classpath.

If some of it looks weird it may be because I have removed a litte bit
to protect the innocent (and the customer).

Lastly, rather than have Java use getResourceAsStream() these two
programs take their properties files as arguments to main().

REM ldapsync.cmd

echo off
set PATH_TO_LOGFILE=d:\opt\xxx\ldapsync\conf\ldapsync. newproperties1
set PROGRAM_PATH=d:\opt\xxx\ldapsync
set JAVA_ARGS=-jar
set PROGRAM_ARGS=%PATH_TO_LOGFILE%
set PROGRAM_NAME=%PROGRAM_PATH%\LDAPsync.jar

java %JAVA_ARGS% %PROGRAM_NAME% %PROGRAM_ARGS%

set PATH=D:\opt\jdk\bin;%PATH%
set PROGRAM_PATH=d:\opt\xxx\adg2oidg.jar
set PATH_TO_LOGFILE=d:\opt\xxx\ldapsync\conf\ADGrp2OID Grp.properties

java -jar adg2oidg.jar %D:\opt\xxx\ldapsync\conf\ADGrp2OIDGrp.properties
-classpath D:\opt\jdk\jdk\jre\lib

REM exit
 
Reply With Quote
 
Lisa
Guest
Posts: n/a
 
      03-16-2005

"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How can I execute a Java program using Windows (XP) Task Scheduler?
>
> Do I have to place a batch program wrapper on it?
>

The command to execute is "schtasks create"
there are a lot of options so I suggest that you read
about it

start -> help and support
when the help and support center window opens,
use the search box to search for "schtasks" and it will explain the whole
thing.

HTH


 
Reply With Quote
 
Peter Guitzmyer
Guest
Posts: n/a
 
      03-16-2005

Thanks to everyone. You've all been a big help.

Mike



On Wed, 16 Mar 2005 18:58:18 GMT, http://www.velocityreviews.com/forums/(E-Mail Removed) (Mike) wrote:

>How can I execute a Java program using Windows (XP) Task Scheduler?
>
>Do I have to place a batch program wrapper on it?
>


 
Reply With Quote
 
Cram TeXeD
Guest
Posts: n/a
 
      03-17-2005
On Wed, 16 Mar 2005 18:58:18 GMT, < Mike > dit :

>How can I execute a Java program using Windows (XP) Task Scheduler?
>
>Do I have to place a batch program wrapper on it?
>


http://javaservice.objectweb.org/ I think it's what you're searching.
By JOnas fathers.

8:0) Cram TeXeD
--
"On ne peut pas ne pas communiquer"
axiome n1 de Paul Watzlawick
<http://texed75.free.fr>
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
scheduling a process using java raj Java 6 02-10-2009 01:05 PM
Recommendations wtd:Good calendar/scheduling app for windows. Squiggle NZ Computing 6 03-10-2008 07:07 AM
Java Team Scheduling Algorithm dlemmermann@gmail.com Java 1 03-12-2007 11:32 PM
Scheduling program for piano tuner and PDA Steve Freides Computer Support 2 06-14-2004 09:58 PM
Re: Java scheduling/calendaring Kristian Bisgaard Lassen Java 2 02-19-2004 02:28 PM



Advertisments