Skip to content
This repository has been archived by the owner on Mar 14, 2018. It is now read-only.

Screen Class not found of SikuliX. #294

Open
princiverma1803 opened this issue Dec 14, 2017 · 15 comments
Open

Screen Class not found of SikuliX. #294

princiverma1803 opened this issue Dec 14, 2017 · 15 comments

Comments

@princiverma1803
Copy link

Hi,
I am using maven in Sikuli Project. I have used following dependency and repository in Pom.xml -

com.sikulix sikulixapi 1.1.0 com.sikulix com.sikulix https://oss.sonatype.org/content/groups/public default true always

Its working for me when I execute this code after creating exe of my code, actually we provide exe only to client but the problem is for Sikuli, exe is not working on other systems.

It executes only till image path but Screen class does not find.
Screen screen = new Screen();

There is no exception in the logs as well.

Kindly suggest some solutions.

Thanks & Regards,
Princi Verma

@RaiMan
Copy link
Owner

RaiMan commented Dec 14, 2017

please be more specific:

  • how do you produce an .exe and what are the contents?
  • do you have any Sikuli(X) specific settings in your dev environment?
  • what do you use for development?
  • does the .exe work on your system from a command line with a basic environment (no special settings for SikuliX)?
  • before touching any SikuliX feature in your java code, take care that a Java system property sikuli.Debug with a value of "3" exists (you might make it settable from outside). gives detailed log.
  • you should step up to 1.1.1 which is on Maven Central (I do not support 1.1.0 any more)

@princiverma1803
Copy link
Author

Hi RaiMan,

  • First I create the jar using Maven clean install and after that I use Launch4j to create the exe from the jar.

  • No I don't have any specific setting for Sikuli(X), but the above mentioned dependency could not download using maven, I was getting Build Failure, so I kept 'wagon-http-lightweight-2.2.jar' in my maven 'apache-maven-3.3.9-bin\apache-maven-3.3.9\lib\ext' folder. After that my build error get resolved.

  • I am using Eclipse IDE for development, we want to integrate our application with Sikuli(X) and written the logic for click action using Sikuli.

  • Actually in our application, we provide exe in the test case (VBA code is written for that) and execute the test case.

  • If I use 1.1.1 version for sikulixapi then it shows me 'Failed to read artifact descriptor for com.github.vidstige:jadb:jar:-v1.0-g94ebf' in Pom's Overview, still my Build is Successful.

But the problem is exe does not work for other system.

And we are not getting the reason. Please help.

Thanks!

@princiverma1803
Copy link
Author

princiverma1803 commented Dec 14, 2017

public StepReturn clickSikuli(String image){
Log.info("Image name is ---> "+image);
String imgPath = sikuliImagePath+"/"+image;
Log.info("Image path is ----> "+imgPath);
File imgFile = new File(imgPath);
if(!imgFile.exists()){
String testCase[] = report.getTestName().split(" ");
String testImgDir = testCase[0].replace(".xlsm", "").trim();;
Log.info("TestCase Name ----> "+testImgDir);
Log.info("Test case image directory name ---> "+testImgDir);
imgPath = testLibraryPath+"/"+testImgDir+"/"+image;
Log.info("image path inside testcase folder ---> "+imgPath);
imgFile = new File(imgPath);
if(!imgFile.exists()){
Log.info("Image does not exist at any Path (Configuration/ORPicture or TestLibrary/test folder), please add the image first.");
return new StepReturn(StepReturnEnum.FAIL);
}
}
Log.info("Before Sikuli Screen ------>>>>>>");
Screen screen = new Screen();
Log.info("Screen class name ------->>> "+screen.getClass());
Log.info("After Sikuli..1" );
Log.info("Image File is ---> "+imgFile);
org.sikuli.script.Pattern imgPattern = new org.sikuli.script.Pattern(""+imgFile);
Log.info("Screen Object is created ----> "+screen);
try {
screen.wait(imgPattern.similar((float)0.60),2).click();
} catch (FindFailed e) {
Log.error("Exception in finding the image ---> "+e);
return new StepReturn(StepReturnEnum.FAIL, "exception in finding the following image '" + image);
}
return new StepReturn(StepReturnEnum.PASS);
}

@princiverma1803
Copy link
Author

I have written the above code.

@RaiMan
Copy link
Owner

RaiMan commented Dec 14, 2017

ok, understood.

My guess for the reasons:
Before packing the .exe, I suppose you are testing from inside Eclipse.
If yes, then at SikuliX init, to the SikuliX eco-system some stuff (e.g. the native libraries) is exported from the sikulix.jar.
If you then run the .exe on that system, it will see the already existing eco-system and not try to export again.
So it has everything at hand and works.

Then trying to run this exe on a system never touched by normal SikuliX before, does not work, because the needed stuff cannot be exported from the sikulixapi.jar embedded inside the .exe.
This was my experience with launch4j 2 years ago and because I did not find an immediate solution, I stopped playing around with launch4j.

You might test that on your system, where the .exe works:
Remove the SikuliX stuff before running the .exe and it should fail.
(running some un-wrapped SikuliX features will restore the stuff from the .jar)

If you know, how to get something out of the .exe, I will try to help you to get on the road.

@RaiMan RaiMan reopened this Dec 14, 2017
@princiverma1803
Copy link
Author

Yes, RaiMan,

Before creating the exe, I execute the code from eclipse, its working and taking the required jar from maven repository - '.m2\repository\com\sikulix\sikulixapi\1.1.0'.
After creating the exe it works for me and if someone else try to create exe from his system, by creating the jar from updated code in eclipse then, exe works for him as well, but for any new system, who only has the exe, does not work.

The problem is, we cannot share the code with everyone, we only provide the exe to execute the test case and it does not work for clickSikuli action.

So, Is the problem with Launch4j?

How the exe can work for others? What could be the possible solutions?

Thanks and Regards,
Princi Verma

@princiverma1803
Copy link
Author

I tried to execute the test case with .exe after removing the sikulixapi from maven repository and test case run without any problem.

@RaiMan
Copy link
Owner

RaiMan commented Dec 15, 2017

With removing "SikuliX stuff" I meant the folder in your application store according to
http://sikulix-2014.readthedocs.io/en/latest/basicinfo.html#sikulix-system-specifics

If you delete at least the folder

SikulixLibs_TIMESTAMP (the place for the exported native libraries)

then I guess the .exe will not work (reason see above).

A quick solution can only be, to have the sikulixapi.jar on the system running the .exe somewhere and take care, that she place is on the java class path at runtime. In this case, sikulixapi.jar need not be in the .exe.

Might be, that launch4j has some support for that.

@princiverma1803
Copy link
Author

Hi RaiMan,

Yes got your point. Now this is working for others also.

Thanks a lot !

Regards,
Princi Verma

@RaiMan
Copy link
Owner

RaiMan commented Dec 15, 2017

Please give me a short description of your concrete solution. Thanks.

@princiverma1803
Copy link
Author

Actually, I just copied my auto generated 'Sikulix' folder (inside '\AppData\Roaming' folder), to the system I wanted to run the exe and it worked.
Thanks !

@RaiMan
Copy link
Owner

RaiMan commented Dec 15, 2017

ok, thanks.

Hoped, you had a solution based on some special launch4J setup :-(

... I have it now on the list again.

last question:
what did you do to secure your code in the .exe?
In my opinion it is not safe, if you did nothing:

  • crack the .exe back to its contents
  • decompile the Java class files

@princiverma1803
Copy link
Author

Hi RaiMan,

We don't have done any implementation to secure the code in .exe.
Kindly suggest how we can secure our code.

Thanks & Regards,
Princi Verma

@RaiMan
Copy link
Owner

RaiMan commented Dec 18, 2017

Kindly suggest how we can secure our code.

I have no idea currently, sorry. I only wanted you to be aware of that.

Usually people ask for the .exe variant with SikuliX scripts or programs, because they think their code would be safe against copyright violation. But principally it is not safer, as when you publish your product as a simple runnable jar file.

@princiverma1803
Copy link
Author

Ohh, Ok.... No Problem.

Thanks !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants