sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #40922
[Bug 1647621] [NEW] [1.1.1] images not found in runnable jar at root level --- use at least one folder level
Public bug reported:
Hello all,
I'm currently running Eclipse Mars.2 Release (4.5.2) with the 64-bit
jdk1.7.0_79. I am not building a Maven project (that I'm aware of). I
simply started a brand new Java Project in Eclipse and imported the
Sikuli jar into the project.
I ran the following block of code that helped me to narrow down my
setBundlePath options (I think):
String clazz = "testAPI.Test";
String imgFolder = "/imgs";
String img = "test.png";
String inJarFolder = clazz + imgFolder;
if (ImagePath.add(inJarFolder)) {
Debug.info("Image Folder in jar at: %s", inJarFolder);
else {
Debug.error("Image Folder in jar not possible: %s", inJarFolder);
}
Sorry about the formatting above, I'm not sure how to get it to show in
blocks.
But any way, that little block of code came from
http://sikulix-2014.readthedocs.io/en/latest/scripting.html and led me
to create the following two lines of code inside of my Main.java file:
ImagePath.setBundlePath("Main/");
ImagePath.add("Main/");
My current project structure looks like this:
[Main Project Name]
-> src
->-> (default package)
->->-> Main.java
-> resources
->-> image1.png
->-> image2.png
->-> image3.png
->-> etc...
When I run the project in Eclipse, it works perfectly. No issues at all.
However, when I export this as a runnable jar (with the Library
Handling: option set to "Package required libraries into generated JAR")
and then subsequently run it like "java -jar [File.jar]" I get the
following errors:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.ExceptionInInitializerError
at Main.main(Main.java:50)
... 5 more
Caused by: java.lang.NullPointerException
at org.sikuli.script.RunTime.init(RunTime.java:635)
at org.sikuli.script.RunTime.get(RunTime.java:291)
at org.sikuli.script.RunTime.get(RunTime.java:126)
at org.sikuli.script.RunTime.get(RunTime.java:316)
at org.sikuli.script.Region.<clinit>(Region.java:31)
... 6 more
I'm assuming this has to do with it not being able to find the images.
When I open the jar with 7-zip, all of the images are in the root of the
jar as well as "Main.class" -- so I thought I had this thing setup
right.
Can anyone help me with this? I'm needing to get this solved drastically
as I'm so sick of working with it... Thank you so very much for whatever
help I can get!
** Affects: sikuli
Importance: High
Assignee: RaiMan (raimund-hocke)
Status: Fix Committed
** Changed in: sikuli
Status: New => Fix Committed
** Changed in: sikuli
Importance: Undecided => High
** Changed in: sikuli
Assignee: (unassigned) => RaiMan (raimund-hocke)
** Changed in: sikuli
Milestone: None => 1.1.1
--
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1647621
Title:
[1.1.1] images not found in runnable jar at root level --- use at
least one folder level
Status in Sikuli:
Fix Committed
Bug description:
Hello all,
I'm currently running Eclipse Mars.2 Release (4.5.2) with the 64-bit
jdk1.7.0_79. I am not building a Maven project (that I'm aware of). I
simply started a brand new Java Project in Eclipse and imported the
Sikuli jar into the project.
I ran the following block of code that helped me to narrow down my
setBundlePath options (I think):
String clazz = "testAPI.Test";
String imgFolder = "/imgs";
String img = "test.png";
String inJarFolder = clazz + imgFolder;
if (ImagePath.add(inJarFolder)) {
Debug.info("Image Folder in jar at: %s", inJarFolder);
else {
Debug.error("Image Folder in jar not possible: %s", inJarFolder);
}
Sorry about the formatting above, I'm not sure how to get it to show
in blocks.
But any way, that little block of code came from
http://sikulix-2014.readthedocs.io/en/latest/scripting.html and led me
to create the following two lines of code inside of my Main.java file:
ImagePath.setBundlePath("Main/");
ImagePath.add("Main/");
My current project structure looks like this:
[Main Project Name]
-> src
->-> (default package)
->->-> Main.java
-> resources
->-> image1.png
->-> image2.png
->-> image3.png
->-> etc...
When I run the project in Eclipse, it works perfectly. No issues at
all. However, when I export this as a runnable jar (with the Library
Handling: option set to "Package required libraries into generated
JAR") and then subsequently run it like "java -jar [File.jar]" I get
the following errors:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.ExceptionInInitializerError
at Main.main(Main.java:50)
... 5 more
Caused by: java.lang.NullPointerException
at org.sikuli.script.RunTime.init(RunTime.java:635)
at org.sikuli.script.RunTime.get(RunTime.java:291)
at org.sikuli.script.RunTime.get(RunTime.java:126)
at org.sikuli.script.RunTime.get(RunTime.java:316)
at org.sikuli.script.Region.<clinit>(Region.java:31)
... 6 more
I'm assuming this has to do with it not being able to find the images.
When I open the jar with 7-zip, all of the images are in the root of
the jar as well as "Main.class" -- so I thought I had this thing setup
right.
Can anyone help me with this? I'm needing to get this solved
drastically as I'm so sick of working with it... Thank you so very
much for whatever help I can get!
To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1647621/+subscriptions
Follow ups