简体   繁体   English

使用Windows Scheduler计划任务以运行.jar文件以及.ini配置文件

[英]Scheduling task with windows scheduler to run .jar file along with .ini configuration file

I am able to run .jar using windows task scheduler but what do I have to do if I have a configuration file(.ini) in project root folder and my .jar file in project distribution folder. 我可以使用Windows Task Scheduler运行.jar,但是如果我在项目根文件夹中有一个配置文件(.ini),在我的项目分发文件夹中有.jar文件,该怎么办。

In my 1st sample program without configuration file, I am executing the .jar file alone by adding -jar PathTo .jar File in "Add Argumnets (optional)" pane, the program runs fine. 在没有配置文件的第一个示例程序中,我通过在“添加Argumnets(可选)”窗格中添加-jar PathTo .jar文件来单独执行.jar文件,程序运行正常。

But in another program with configuration file, if I execute with the same command as above, nothing gets executed. 但是在另一个带有配置文件的程序中,如果执行与上述相同的命令,则不会执行任何操作。 And I am assuming this happens because the argument points to distribution folder and the configuration file is in the root folder. 我认为这是因为参数指向分发文件夹,而配置文件位于根文件夹中。

Any ideas/help is greatly appreciated 任何想法/帮助将不胜感激

Assuming you have the following file structure (and if I didn't misunderstand your description): 假设您具有以下文件结构(如果我没有误解您的描述):

rootPath/
  +-- ConfigFile.ini
  +-- distFolder/
        +-- YourApp.jar

You should set task parameters like this: 您应该像这样设置任务参数:

Action: Start a program 行动:启动程序
Program/script: "C:\\Program Files (x86)\\Java\\jre7\\bin\\javaw.exe" 程序/脚本: “ C:\\ Program Files(x86)\\ Java \\ jre7 \\ bin \\ javaw.exe”
Add arguments (optional): -jar "rootPath\\distFolder\\YourApp.jar" 添加参数(可选):- jar“ rootPath \\ distFolder \\ YourApp.jar”
Start in (optional): rootPath 开始于(可选): rootPath

By this way, Windows scheduler should init your java application in rootPath directory and it shouldn't have problems to load ConfigFile.ini 通过这种方式,Windows调度程序应在rootPath目录中初始化Java应用程序,并且加载ConfigFile.ini应该没有问题。

Note: C:\\Program Files (x86)\\Java\\jre7\\bin\\javaw.exe is my java path, just use yours of course. 注意: C:\\Program Files (x86)\\Java\\jre7\\bin\\javaw.exe是我的Java路径,请当然使用您的Java路径。 Also note is necessary use javaw.exe . 另请注意,必须使用javaw.exe Finally at Start in section, rootPath doesn't be quoted. 最后,在“ Start in部分中,没有引用rootPath

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM