sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #24546
Re: [Question #244845]: HowTo Java: evaluate Sikuli ImagePath inside Eclipse and outside running from built jar
Question #244845 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/244845
Status: Answered => Open
jeff radom is still having a problem:
Hi Raiman,
Unfortunately your suggestion didn't help.
This line never worked for me ImageLocator.addImagePath(
imgpath);
Adding of org.sikuli.basics.ImageLocator to my Eclipse project. Any method
in a ImageLocator class not available for me. It might work for a jar
file you use but with a one I got. So, can you please just email me your
Sikuli jar file. I've got mine by downloading from a sikuli.org site ante
installing. Or, if you suggest what particular subdirectory I can put my
images. I've tried many options including .sekuli but nothing worked. can
you suggest if istead of using ant we'll use maven for example can that fix
my issue or any other suggestion how to run using java, Mac OS and from a
server. I feel very bad about not having an easy way to run Sikuli from a
sever using Jenkins because I've suggested it to the team after
evaluation. No, I'm thinkg t o use something else or go back Selenium
which we used before. Please, help
Thanks
Jeff
On Mon, Mar 3, 2014 at 8:01 AM, RaiMan <question244845@xxxxxxxxxxxxxxxxxxxxx
> wrote:
> Your question #244845 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/244845
>
> Status: Open => Answered
>
> RaiMan proposed the following answer:
> this is a solution, that works inside Eclipse (running from the compiles
> classes) and outside running from the jar:
>
> import java.io.File;
> import java.io.IOException;
> import java.security.CodeSource;
> import org.sikuli.basics.ImageLocator;
>
> public class Test {
>
> public static void main(String[] args) throws IOException {
> CodeSource src = Test.class.getProtectionDomain().getCodeSource();
> String jarpath = "---NOT_KNOWN---";
> if (src.getLocation() != null) {
> File jar = new File(src.getLocation().getPath());
> if (jar.getName().endsWith(".jar")) {
> jarpath = jar.getParent();
> } else {
> jarpath = jar.getParentFile().getParentFile().getAbsolutePath();
> }
> }
> String imgpath = new File(jarpath, "images").getAbsolutePath();
> System.out.println("images: " + imgpath);
> String workpath = System.getProperty("user.dir");
> System.out.println("work: " + workpath);
> ImageLocator.addImagePath(imgpath);
> System.out.println("test.png? " + ImageLocator.locate("test.png"));
> }
> }
>
> I tested this in Netbeans, where I have this project structure:
> --- test project
> --- build/classes
> --- dist
> --- src
> --- images
>
> when running in eclipse, the images folder is set to the one in the
> project (test/images)
> when running from the jar, it is expected, that there exists a folder
> images in the folder containing the jar.
>
> the rest is ant scripting,
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/sikuli/+question/244845/+confirm?answer_id=2
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/sikuli/+question/244845
>
> You received this question notification because you asked the question.
>
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.