How to Automate Running a Java Class

Asked by Tyson K

I have created a Java class that runs some Sikuli tests. How can I run this class automatically? I have tried using Windows' Task Scheduler without success. I would like to set up a time for this class to run over night.

This is the batch file code I run:
"C:\Program Files (x86)\Java\jre7\bin\javaw.exe" -Dfile.encoding=Cp1252 -classpath C:\C1_Manager\Dev\C1_ManagerAutomation\SikuliX\sikuli-script.jar;C:\C1_Manager\Dev\C1_ManagerAutomation;C:\C1_Manager\Dev\C1_ManagerAutomation\images;C:\C1_Manager\Dev\C1_ManagerAutomation\Guava\guava-16.0.1.jar sikuliAutomation.sikuliTest

It works fine if I open the batch file manually.
When run using Task Manager, the process runs but all tests fail. This is because when the code is called, no internet browser opens.

Any ideas? Thank you.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

I remember, that testing the batch in the TaskManager setup requires admin rights (same as with the mmc windows).

But if it generally works, it should run, when it is scheduled.

Revision history for this message
Tyson K (tyson-knutson) said :
#2

I am running it as an admin. My user also has admin rights.

Running this in a command prompt works:

C:\C1_Manager\Dev\C1_ManagerAutomation>"C:\Program Files (x86)\Java\jre7\
bin\javaw.exe" -Dfile.encoding=Cp1252 -classpath C:\C1_Manager\Dev\C1_ManagerAut
omation\SikuliX\sikuli-script.jar;C:\C1_Manager\Dev\C1_ManagerAutomation;C:\C1_M
anager\Dev\C1_ManagerAutomation\images;C:\C1_Manager\Dev\C1_ManagerAutomation\Gu
ava\guava-16.0.1.jar sikuliAutomation.sikuliTest

I have my Task setup like this:
Action: Start a program
Program/Script: "C:\Program Files (x86)\Java\jre7\bin\javaw.exe"
Add arguments: -Dfile.encoding=Cp1252 -classpath C:\C1_Manager\Dev\C1_ManagerAutomation\SikuliX\sikuli-script.jar;C:\C1_Manager\Dev\C1_ManagerAutomation;C:\C1_Manager\Dev\C1_ManagerAutomation\images;C:\C1_Manager\Dev\C1_ManagerAutomation\Guava\guava-16.0.1.jar sikuliAutomation.sikuliTest

Start in: C:\C1_Manager\Dev\C1_ManagerAutomation

What am I doing wrong?

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of RaiMan
Sent: Wednesday, April 09, 2014 3:51 PM
To: Knutson, Tyson
Subject: Re: [Question #246773]: How to Automate Running a Java Class

Your question #246773 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/246773

    Status: Open => Answered

RaiMan proposed the following answer:
I remember, that testing the batch in the TaskManager setup requires admin rights (same as with the mmc windows).

But if it generally works, it should run, when it is scheduled.

--
If this answers your question, please go to the following page to let us know that it is solved:
https://answers.launchpad.net/sikuli/+question/246773/+confirm?answer_id=0

If you still need help, you can reply to this email or go to the following page to enter your feedback:
https://answers.launchpad.net/sikuli/+question/246773

You received this question notification because you asked the question.

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

Wether you or your user has admin rights does not matter.
When you run the task manager to do the setup and want to test, you have to start the task manager as admin (context menu)

Try this:

Action: Start a program
Program/Script: cmd.exe
Add arguments: /C "C:\Program Files (x86)\Java\jre7\bin\javaw.exe" -Dfile.encoding=Cp1252 -classpath C:\C1_Manager\Dev\C1_ManagerAutomation\SikuliX\sikuli-script.jar;C:\C1_Manager\Dev\C1_ManagerAutomation;C:\C1_Manager\Dev\C1_ManagerAutomation\images;C:\C1_Manager\Dev\C1_ManagerAutomation\Guava\guava-16.0.1.jar sikuliAutomation.sikuliTest

Start in: C:\C1_Manager\Dev\C1_ManagerAutomation

Revision history for this message
Tyson K (tyson-knutson) said :
#4

Thanks for your help, Raimund!

The task runs if the option to run only when user is logged in is checked. Otherwise, not. Looks like a Windows problem, not a Sikuli problem. I will continue to research.