-1

I am designing a java application which needs to run at a specific time. My application is packaged in jar file and this jar should be activated every day at 3 AM in morning. My end Machine is windows machine not a server. Please help me out with this. Myapp.jar is the jar file and its located in D:/Collector/MyApplication/target/MyApp.jar is the location in my system. Right now

java -jar MyApp.jar

is executing fine. But when my system goes off then again I have to initiate the same through command prompt. So I would also require a solution in which when system reboots the jar should be initiated. How to schedule a java program to run daily in Windows?

This answer already is there but I don't want to do it with Task scheduler as it reduces my machine efficiency.

Community
  • 1
  • 1

3 Answers3

0

Windows has a "Task Scheduler", which is what you need to use to run a program on a recurring schedule and/or on machine startup.

Andreas
  • 154,647
  • 11
  • 152
  • 247
0

You can program a task, or make an executable with your jar and place it on startup folder if windows 7 or lower


PROGRAM A TASK (SOURCE)

To Run Task Scheduler using the Windows interface

  • Click the Start button.
  • Click Control Panel .
  • Click System and Maintenance .
  • Click Administrative Tools .
  • Double-click Task Scheduler .

To Run Task Scheduler from the Command Line

  • Open a command prompt. (cmd or click Start, All Programs, Accessories, Command Prompt)
  • At the command prompt, type Taskschd.msc.

STARTUP FOLDER (SOURCE:)

On Windows 7 and earlier versions of Windows, the Start menu contained a “Startup” folder to make this easy. On these versions of Windows, you can simply open your Start menu, locate a shortcut to an application you want to start automatically, right-click it, and select Copy. Next, locate the Startup folder under All Apps in the Start menu, right-click it, and select Paste to paste a copy of that shortcut.

Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109
0

Create a bat file for that you want to achieve and schedule the windows Task Scheduler as listed below.

  1. Click Start
  2. Type Task and then click Task Scheduler

Once the Task Scheduler is open, you can create your own custom task by clicking Create Basic Task. This action starts a wizard that walks you through the process, prompting you with what program you want to execute, as well as how often and what time it should be run.

Manoj Kumar
  • 380
  • 5
  • 20