java - Maven Jar file read external images -


hello changed javafx8 project maven works except loading files lying next jar. worked before not more.

folder structure:

icons load located in /target/icons jar file located in /target

my code read files following:

    string applicationdir = (new file(".")).getabsolutepath();     string iconsdir =  applicationdir+"/target/icons/";     file[] files = new file(iconsdir).listfiles();       (file file : files) {          if (file.getname().endswith(".png")) {             system.out.println(file.getabsolutepath());              image img = new image(file.getabsolutepath());             iconlibrary.put(file.getname().split("\\.")[0].touppercase(), img);         }      } 

it enters loop , findes files, crashes when new image(file.getabsolutepath()) called invalid url: invalid url or resource not found exception.

i tried kind of stuff toexternalform() , on nothing helped, still exception no matter do.

i lost , maybe can give me hint doing wrong.

thanks in advance

robi

hey guys got running!

the solution was:

 image  img = new image(file.touri().tostring()); 

thanks help

what weird, makes difference in directory running java -jar jarfile.jar works if in same folder


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -