saeed arash
saeed arash

Reputation: 935

how can I run a java program automaticlly

I have a java package, I want to my program be runned every night at 0 o'clock automaticlly, how can I do this work?

Upvotes: 0

Views: 171

Answers (2)

Will
Will

Reputation: 14559

You can either schedule in your own OS. On *nix, there is cron. I'm not sure what is used in windows.

Or you can make your own java program schedule: on running it, it sets a times to execute your task in a specific time.

You could use a Thread.sleep() counting the time from now until midnight, but that's a poor-man's solution. Quartz is your man, as it works schedulling your tasks.

If you choose the schedulling path, you can't forget to run your application in the OS startup

Upvotes: 1

AlexR
AlexR

Reputation: 115388

Generally you have 2 solutions:

  1. Create application that runs your code every night, i.e. implement scheduling yourself. Obviously you can (and should) use tools that help you to do scheduling.
  2. Use OS-specific tools. For example cron for unix and windows task scheduler for windows.

Upvotes: 1

Related Questions