Menu

Cannot properly reference resource files (Beginner)

Help
2016-11-14
2016-11-16
  • Evan Belcher

    Evan Belcher - 2016-11-14

    I am trying to wrap my first program with Launch4J. I am trying to access two images in my application.
    I initially had it like this

    ImageIO.read(new File("src/res/Blank_Marching_Band_Drill_Design_Paper-1.jpg"))
    

    Which obviously did not work correctly in L4J. After looking around, I saw suggestions using ClassLoader, but while I got that to work inside of Eclipse, the same code did not work after being run from the executable. The root of the exe seems to be the src folder of the project, which makes referencing a challenge. Can anyone help?

    Related question: How do I print to the Launch4J console for debugging? I'm using the Lanuch4J 3.9 GUI.

     
  • Grzegorz Kowal

    Grzegorz Kowal - 2016-11-16

    Launch4j is using the ClassLoader for that purpose, have a look at Util.java or loadImage method in any net.sf.launch4j.from class. The load image takes a relative path: loadImage("images/open16.png"), try without 'src/'.

    Grzegorz

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.