I want to get the picture path in .jar. I have opened my app (.jar) as a winrar, and I found my picture, but path of this file not works:
BufferedImage myPicture = ImageIO.read(new File("/windows.png"));
JLabel picLabel = new JLabel(new ImageIcon(myPicture));
It means it works in IntelliJ IDEA but not as app. So what is this file path(as app, not IDE)? Thanks for help and sorry for my english!
Try this
InputStream in = this.getClass().getResourceAsStream("/SomeTextFile.txt");
You can find more detailed answer eg. here How to really read text file from classpath in Java