IntelliJ IDEA artifact.jar and ImagePath
Hello, I am having trouble locating pattern images bundled inside .jar in IntelliJ IDEA IDE.
My project is setup like this:
https:/
And the code is:
ImagePath.
for (ImagePath.
print(
}
Which works nicely when I run the project. I get:
null
/C:\(...)\patterns/
And everything works. But when I try to pack it inside .jar and I build an artifact and run it, I just get:
null
null
Weirdly the ImagePath.
This is the .jar structure when I unzip it:
https:/
Thanks for any help.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Sikuli Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Jaroslav Novotny
- Solved:
- 2020-10-26
- Last query:
- 2020-10-26
- Last reply:
- 2020-10-25
RaiMan (raimund-hocke) said : | #1 |
In the jar there is a folder "main" and your running class is named "Main".
This might lead to a confusion.
I made a new project just to investigate, got some new info. I was hoping it was conflict in the "main" name, but looks like something else.
This is the code:
import org.sikuli.
public class SikuliTest {
public static void main(String[] args) {
boolean path_add_success = ImagePath.
for (ImagePath.
}
Pattern pattern = new Pattern(
}
}
When running from IntelliJ all is fine. When from this .jar (unzipped structure: https:/
e:\....
SikuliTest/
ImagePath: null
ImagePath: null
[error] Image: load: failed: jar:file: /E:/...
Weirdly the "/" gets doubled.
I can provide this test project and .jar if needed.
RaiMan (raimund-hocke) said : | #4 |
Yes, send me the stuff zipped to sikulix-
RaiMan (raimund-hocke) said : | #5 |
got the stuff - will come back
RaiMan (raimund-hocke) said : | #6 |
Here is my conclusion:
- Do not use a trailing slash:
boolean path_add_success = ImagePath.
should be:
boolean path_add_success = ImagePath.
This does not harm in the "run-inside-
(I will evaluate this further and make it more graceful)
- an imagepath "class/folder" is accepted in all cases and works inside IDEA and in the jar situation
... but it seems, that only the first jar found in imagepath is evaluated (this is a bug)
I made my tests with Java 8 and Java 11.
The jar situation does not work with Java 15 (under evaluation, Java 15 is currently not supported anyways)
Yes, all works without the trailing slash! Thanks!