sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #25620
[Question #247998]: java.lang.NoClassDefFoundError: org/sikuli/script/Screen when calling Screen object from jar file through command line
New question #247998 on Sikuli:
https://answers.launchpad.net/sikuli/+question/247998
Steps to reproduce:
Step 1: Create a new java project in eclipse
Step 2: Add
a. server-windows-0.0.1-SNAPSHOT-jar-with-dependencies.jar
b. sikuli-java.jar
c. sikuli-remote-client-0.0.1-SNAPSHOT.jar
d. sikuli-script-windows.jar
jar to the java build path.
Step 3: Create a new class and write the following code in the class file
package main.java.com;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
public class SikuliDemo
{
public static boolean selectTabItem(String sTabItemName)
{
Screen screen = new Screen();
Pattern image = null;
try
{
if(sTabItemName.equalsIgnoreCase("Chrome"))
{
image = new Pattern("images/IconChrome.png");
screen.wait(1000);
if (screen.exists(image,10) != null)
screen.click(image,0);
}
return true;
}
catch(Exception e)
{
System.out.println(e.getMessage());
return false;
}
}
public static void main(String args[]) throws Exception
{
System.out.println(args[0]);
selectTabItem(args[0]);
}
}
Step 4: Export the project into a jar file.
Step 5: Open Command Prompt and execute the exported jar file using the command
"java -jar sikuli-workspace.jar "Chrome""
Expected: The chrome icon should be clicked
Actual Behavior :
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Accounts
Exception in thread "main" java.lang.NoClassDefFoundError: org/sikuli/script/Screen
at main.java.com.SikuliDemo.selectTabItem(SikuliDemo.java:11)
at main.java.com.SikuliDemo.main(SikuliDemo.java:44)
Caused by: java.lang.ClassNotFoundException: org.sikuli.script.Screen
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Please help me how to execute the sikuli code inside the jar file from command line.
Thanks,
Sonu Davidson C.B
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.