how to run script by commond? I did not find runScript.cmd

Asked by lisa hoo

Hi all,

I want to run sikuli script. My code was 'os.system("java -Xms256m -Xmx512M -jar sikuli-java.jar -r TestRunner.sikuli ' but got the error message 'Failed to load Main-Class manifest attribute from sikuli-java.jar'.

 I have read the question '101812' but can't resolve my problem.

Version:1.0.1
OS: Windows7,32bit

Can anyone help me solve this?
Thank you in advance.

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
lisa hoo (xiaoxia307) said :
#1

I have resolved the 'unable to access jar file' issue.

 'Failed to load Main-Class manifest attribute from sikuli-java.jar' still can't be there.

Revision history for this message
lisa hoo (xiaoxia307) said :
#2

Besides, Sikuli IDE works fine. The version is :1.0.1.

 'Failed to load Main-Class manifest attribute from sikuli-java.jar' is still there.

Revision history for this message
lisa hoo (xiaoxia307) said :
#3

The 'MANIFEST.MF''s content is as follows:

Manifest-Version: 1.0
Created-By: 23.7-b01 (Oracle Corporation)
Archiver-Version: Plexus Archiver

I noticed there was no 'Main Class' item, maybe this is the cause?

Revision history for this message
lisa hoo (xiaoxia307) said :
#4

I added 'Main-Class: org.sikuli.script.SikuliX' in 'MANIFEST.MF', and then run 'java -jar sikuli-java.jar -r test.sikuli' from cmd.

The error message is as follows:

Exception in thread "main" java.util.ServiceConfigurationError: org.sikuli.basics.IScriptRunner: Provider org.sikuli.scriptrunner.JythonScriptRunner not found.
 at java.util.ServiceLoader.fail(Unknown Source)
 at java.util.ServiceLoader.access$400(Unknown Source)
 at java.util.ServiceLoader$LazyIterator.next(Unknown Source)
 at java.util.ServiceLoader$1.next(Unknown Source)
 at org.sikuli.basics.SikuliX.getScriptRunner(SikuliX.java:193)
 at org.sikuli.basics.FileManager.getScriptFile(FileManager.java:566)
 at org.sikuli.basics.SikuliScript.main(SikuliScript.java:171)
 at org.sikuli.script.SikuliX.main(SikuliX.java:50)

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

sikuli-java.jar cannot be used to run scripts (it is for use with Java programming or external Jython and other Java aware scripting languages))

you either have to use sikuli-ide.jar or sikuli-script.jar.

On Windows it is recommended to use the bundled cmd-scripts.

If you want to run scripts using sikuli-java.jar, then this must be on the class path and you have to use an external Jython (installed yourself) to run the script (jython test.sikuli\test.py).

But in these cases, you have to tell Sikuli separately (e.g. using setBundlePath()), where the script finds the images.
And you need at the beginning of the script:
import org.sikuli.basics.SikuliXforJython
from sikuli import *

(see https://github.com/RaiMan/SikuliX-API/wiki/Usage-in-Java-programming)

Revision history for this message
lisa hoo (xiaoxia307) said :
#6

Thanks RaiMan, that solved my question.