← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #284507]: Import error in One-jar "No module named Sikuli"

 

Question #284507 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/284507

Description changed to:
Hi,
I am trying Sikulix for the first time to automate an application in my pc.
I tried to code in Jython in Eclipse IDE importing Sikulixapi.jar.

I have a simple practice code that identifies and click Start button and then open Arduino by double clicking on icon in Desktop.
I wished to try bundling it with one-jar using 'ant' tool as documented in https://github.com/EnigmaCurry/Single-JAR-Jython-Example

I followed the same procedure mentioned in this page and I was able to
get ant build a .jar successfully. But if I try to run it using java
-jar builtjarfile.jar, I get many errors message from this line:

Caused by: Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "__pyclasspath__/learning/__init__.py", line 3, in <module>
ImportError: No module named Sikuli

I tried to build the sample application in the github link above and I
was able to get it working. It was able to import from apache poi libary
in its /lib folder.

Here's my folder structure :
BuildingJar 
    ---/java-src
         --- main.java
    ---/lib
              ---jython-full.jar
              ---sikulixapi.jar 
    ---/onejar-src (copied from github repo above)
    ---/src
         ---/Learning
               --- __init__.py
               --- arduino.png
               --- starticon.png
    ---build.xml

This is the source of __init__.py : (This worked when it ran from
Eclipse IDE - It was able to click start icon and then double click
arduino icon in desktop)

#-*- coding: utf-8 -*-
import org.sikuli.script.SikulixForJython
from Sikuli import *     #This is line 3!
import os 
import time
scr=Screen(0);
def main():
    scr.click("starticon.png")
    scr.doubleClick("arduino.png")
    time.sleep(5);
 
This is the source of main.java inside java-src folder

import org.python.core.PyException;
import org.python.util.PythonInterpreter;

public class Main {
    public static void main(String[] args) throws PyException{
	PythonInterpreter intrp = new PythonInterpreter();
	intrp.exec("import learning");
	intrp.exec("learning.main()");
    }
}

------

I have compared my code and setup with the example app from the github
repo. While the app built with ant from this repo is able to generate a
.jar which has the apache poi library in libs and get it working to
generate sample spreadsheet in my desktop,  I am unable to get
sikulixapi.jar importing sikuli and get it working on my sample app.

Can you please help me with this?

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.