M
M
MaxLich2017-10-08 23:20:26
Java
MaxLich, 2017-10-08 23:20:26

Why can't resources from a jar file be loaded on my Windows?

Hello. Wrote a small program. In this program, I assign icons to the buttons. I take icons from the jar file itself. I write the path like this:

private static final String PATH_TO_IMAGE_RETURN =  File.separator + "images" + File.separator + "cross.png";

Then I use it like this:
Icon icon =  new ImageIcon(getClass().getResource(PATH_TO_IMAGE_RETURN));

On Linux everything works fine, on windows it doesn't.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2017-10-08
@MaxLich

Resource paths are always separated by / regardless of the operating system.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question