使用 Windows 调度程序运行 jar 文件 [英] Run a jar file using windows scheduler

查看:37
本文介绍了使用 Windows 调度程序运行 jar 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 jar 文件,我想从 windows 7 中的 windows 调度程序运行它

I have jar file which I want to run from windows scheduler in windows 7

我在 path/script 中给出了 java.exe 的路径,在 arguments 字段中给出了 -jar c:abcab.jar.

I have Given the path of java.exe in path/script and -jar c:abcab.jar in the arguments field.

但它没有运行.我也在bat文件的帮助下尝试过,但它没有运行.运行jar文件需要做什么?

But it does not run. I have also tried it with help of a bat file, but it does not run. What is needed to be done to run the jar file?

我的 jar 文件创建文件并更新数据库.

My jar file creates files and updates a database.

推荐答案

从任务计划程序运行一个 java jar (Windows 7 Professional 64 bit)

我会将其配置为每 5 分钟运行一次.

Run a java jar from Task Scheduler (Windows 7 Professional 64 bit)

I'll be configuring it to run every 5 minutes.

第 1 步,安装 java,确保它在命令行中可用

您应该能够从裸 cmd 命令行运行您的 java jar.像这样指定完整的java目录:(这是我使用的命令)

You should be able to run your java jar from the bare cmd commandline. Specify the full java directory like this: (This is the command I used)

C:ProgramDataOracleJavajavapathjava.exe -jar C:
epocurium.jar

第 2 步,打开任务调度器:

在开始菜单搜索栏中,搜索计划程序",应该会弹出任务计划程序".它隐藏在控制面板中:控制面板->系统和安全->管理工具->任务计划程序.

In the Start menu search bar, search for "scheduler" and "Task Scheduler" should pop up. It is buried in the control panel: Control Panel -> System And Security -> Administrative tools -> Task Scheduler.

第三步,新建一个定时任务:

在左窗格中,右键单击任务计划程序库".选择:新建基本任务".给它任何名字.

In the left pane, right click "Task Scheduler Library". Choose: "New Basic Task". Give it any name.

选择下一步.点击每日",(每分钟重新运行的配置稍后进行).

Choose next. Click "Daily", (the configuration for re-runs every minute will be done later).

选择下一步.每 1 天重复一次.让它从现在开始 5 分钟.选择下一步.单击启动程序".

Choose next. Recur every 1 day. Have it start a 5 minutes from now. choose next. Click "Start a program".

第 4 步,配置您的 java 以运行:

在程序/脚本"框中输入您的 java 的完整路径,您的路径可能不同.使用 cmd 命令仔细检查 where java

In the "Program/script" box put the full path to your java, your path may be different. Double check with cmd command where java

C:ProgramDataOracleJavajavapathjava.exe

在添加参数"框中输入:

In the "Add arguments" box put this:

-jar C:
epocurium.jar

点击下一步,点击完成.

Click next, click finish.

第 5 步,右键单击新任务以进行进一步配置:

右键单击您的项目 -> 属性.

Right click your item -> Properties.

选择气泡:无论用户是否登录都运行"

Choose the bubble: "Run whether user is logged in or not"

在触发器"标签下.选择您的每日任务并选择编辑.

Under the "triggers" tab. Select your Daily task and choose Edit.

第 6 步,配置重复任务触发器

开始任务:按计划".

选择每重复一次任务:5 分钟".选择启用的复选框.单击确定.保存.

Choose Repeat task every: "5 minutes". Choose the enabled checkbox. Click ok. Save.

系统将提示您输入 Windows 用户名和密码.添加并按 OK.

You will be prompted for your windows username and password. Add and press OK.

第 7 步,确保其正常工作

等待 5 分钟以使其运行.或者通过右键 -> 运行来强制运行它.

Wait 5 minutes for it to run. Or force run it by right clicking -> Run.

右键单击您的任务,选择属性.选择历史"标签.

Right click your task, choose properties. Choose "History" tab.

应该有一行显示它运行的时间.如果您想知道它是否成功完成,您必须将输出通过管道传输到日志文件.

There should be a row there revealing when it ran. If you want to know if it completed successfully, you'll have to pipe your output to a log file.

第 8 步,看看它是否在重新启动后仍然存在

重新启动计算机,看看它是否保持开启状态.如果是,你就完成了.

Reboot the computer, and see if it stays on. If it does you are done.

这篇关于使用 Windows 调度程序运行 jar 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆