this question is also in the I/O and stream and im sorry i do not really know hos to delet post and i moved it here because i dont think it belong to this section anymore if you know how to delet post hope you can guide me
i have a class GUI that edit multiple png and show it in the window if i execute this code from eclipse it work perfectly but when i want to export to a jar file and launch it (in windows) some weird error message are poping and i do not really understand it
here is my class that edit and read my png
i hope you can explain why is it working in eclipse ide but not in a jar file
Please check the location of the XXX.png file. Eclipse uses paths relative to the root of the project (I think) but if you run the program from the command line, paths may be relative to the current directory.
I think you will find that the absolute path to the files you're copying is not what you think it is. Most likely, you are starting from a different home directory. The simplest way to fix this would be to put an absolute path in your "path" constant, meaning one that begins with / or (for Windows) a drive, like "C:". Something like this:
Norm is correct. Resources that are part of the project sources are packaged into the JAR and need to accessed through Class.getResourceAsStream(). The path to use is relative to the path of the class that you called the method on. The easiest thing to do is put the resource in the same package as the source file you will be using it in. Otherwise, use an absolute path. Absolute paths are relative to the root package (the source folder):
hi thanks you Stephan and Norm for your reply and explain that was a hudge help i have edited my code according to your suggestion i can load at least my first png but he show me error telling me that NoSuchFileException because he cant find the file i guess and i dont really understand why when i launch my jar file he load the first png (tictactoe_sav) but cant load the next and i cant make a getRessourcesAsstream to my file b because i want to delet it (replace it)after and cant do that if i use getressources
As Norm already pointed out, you don't perform File operations on resources. They are not files, resources are compressed into your JAR. Resources are only there to be read by your application.
What you're doing doesn't make sense. Why would you want to copy tictactoe_sav.png to tictactoe.png? Just keep the combined image in memory, don't save it to disk. Even if you insist on saving it to disk, don't save it to your project folder. When your application is deployed on a client system, the installation folder will not reflect your project directory layout.
Why are you combining the images into one at all? If you're using a GUI framework such as Swing, just paint the images to a canvas on the fly, instead of combining them into one image first.