Error when running the application outside the eclipse ide - it seems that java cannot find the image path

Thanks for help

Running through the eclipse, it runs perfectly. But at .jar

E:_projetos\bot-java-template-main\target>java -jar FirstBot-1.0-jar-with
-dependencies.jar
java.lang.NullPointerException
at javax.swing.ImageIcon.(Unknown Source)
at dev.botcity.framework.bot.DesktopBot.addImage(DesktopBot.java:87)
at dev.botcity.main.FirstBot.load(FirstBot.java:48)
at dev.botcity.main.FirstBot.(FirstBot.java:12)
at dev.botcity.main.FirstBot.main(FirstBot.java:56)
java.lang.NullPointerException
at dev.botcity.framework.bot.DesktopBot.findSubimage(DesktopBot.java:133

Hi @eduzortea ,

When you’re running your bot on Eclipse, the bot is looking for resources at:

/src/recources/

In that folder are all images used by the bot to recognize UI elements.

However, when you build a runnable jar, the resource images are placed in the jar root. Use o zip extractor to check it.

Therefore you need to change your addImage() methods to addImage(“label”, “label.png”) without “/src/resources/”

1 Like