Sikulixapi-2.0.4 not working after creating a jar of my Java SWt desktop application
Hi,
I have add sikulixapi-2.0.4 jar in my project's build path as external jar and implemented the functionality which I required. Its is working fine as fas a considered running the application in eclipse IDE. But when I export it as jar sikuli doesn't work at all. As I tried to run my jar via commandline to se verbose it enters the loop in while I havw written Sikuli logic but never ever passes the condition and feels like goes in infinite loop nor gives any error. Also I don't think there might be any error in my code. Here is the code below.
----------------- Code starts -------
@Override
public String call() throws Exception {
// ImagePath.
ImagePath.
+ "images");
Screen screen = null;
try {
System.
screen = new Screen();
while (true) {
if (screen.
System.
screen.
// Call captureAndSaveS
// and saving screenshot.
captureAnd
// Continue closing process.
screen.
screen.
screen.
screen.
screen.
break;
} else {
System.
screen.
}
}
} catch (Exception ex) {
ex.printStac
}
return "";
}
-------
I have implemented it as a thread to run when the image matches with my desktop application.
Kindly help and suggest the steps required. I am new to Sikuli.
Thanks
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Sikuli Edit question
- Assignee:
- No assignee Edit question
- Last query:
- 2020-04-30
- Last reply:
- 2020-05-01
RaiMan (raimund-hocke) said : | #1 |
Sorry, I do not understand your problem.
The printout should show, what happens.
Kunal Deshpande (dkunal96) said : | #2 |
I am trying to create a desktop application using java which uses sikulixapi-
RaiMan (raimund-hocke) said : | #3 |
ok.
What a bout the printout, when run from commandline?
add -Dsikuli.Debug=3 to the java command. this should create some SikuliX debug output.
... and put the sikulixapi.jar on the classpath, to be sure it is there.
Kunal Deshpande (dkunal96) said : | #4 |
Okay I will paste the trace here. In classpath you mean in my application classpath in eclipse or one where jdk is installed on my machine?
Kunal Deshpande (dkunal96) said : | #5 |
Is this the correct way if I specify jar file during runtime? javac –classpath C:\dependency\
RaiMan (raimund-hocke) said : | #6 |
--- classpath at runtime
java -classpath C:\dependency\
--- trace
You have several System.out.println in your code. So if you run your exported jar from commandline, there should be some printout.
Kunal Deshpande (dkunal96) said : | #7 |
--- Classpath issue taht you suggested above.
Error: Could not find or load main class MyApp.jar
# command used as suggested: java -classpath C:\dependency\
--- Trace after adding -Dsikuli.Debug=3 using command as java -jar -Dsikuli.
[debug] RunTime:temp folder ok: C:\Users\
and when I navigate to it it the folder is empty.
Below is my folder structure from where I am running jar file.
MyApplication >
images > # This is where images are stored for sikuli
lib >
Kunal Deshpande (dkunal96) said : | #8 |
I found that I have already added sikulixapi-
Kunal Deshpande (dkunal96) said : | #9 |
Another info I am executing my sikuli commands using Threads in Java. Hope it doesn't have any issue. Becuase it works fine in eclipse.
Kunal Deshpande (dkunal96) said : | #10 |
Its not even evaluating this "if (screen.
I am unable to figure it out why its running perfectly in IDE and not after creating runnable jar of the application :( .
Kunal Deshpande (dkunal96) said : | #11 |
Can you please help me?
RaiMan (raimund-hocke) said : | #12 |
--- Its not even evaluating this "if (screen.
How do you know, that it is not executing the if.... ?
I guess your problem when running the jar is, that the images cannot be located correctly in the file system, in which case the exists() simply does nothing and returns false.
change your code so:
String image = createFullPathO
System.
if (screen.
This will show you the generated filename.
So you can check, wether it is valid.
Kunal Deshpande (dkunal96) said : | #13 |
I created a path as you said and also checked using new File(image)
RaiMan (raimund-hocke) said : | #14 |
again: what about the printout?
Kunal Deshpande (dkunal96) said : | #15 |
It was showing files exits and the filepath was also correct. Is it the issue with corporate systems because I am developing my application in my office.
RaiMan (raimund-hocke) said : | #16 |
It would be much easier if you do not only talk about, what YOU are seeing, but also just paste the print output of your program here together with your source code.
Can you help with this problem?
Provide an answer of your own, or ask Kunal Deshpande for more information if necessary.