This seems like it should be simple, but I cannot for the life of me figure it out. All I want to do is load an image into a swing JLabel and display it, but I'm going to have to make a JAR of the program and submit it for grading, so I need to be able to get the path of the image file relative to the JAR (at least I think that's how it works - I've never made a JAR before. Right now I'm just trying to load it from a path relative to my netbeans project). I've tried at least 20 different combinations of paths, file locations within the project, etc., but nothing works. I found this and tried to do what people were suggesting, but it didn't work and I don't understand it very well (I've never seen the class/ClassLoader thing before and after trying to read through the documentation for them I'm still pretty iffy on what they're all about).
Anyways, here's the test class I've been using to try to figure this out in its current iteration. Right now the image I want to load is in src/resources and the class is in src/imagedisplaytest
What's the best way to do this? Also, if anybody has any good resources for learning about the class and/or ClassLoader things could you please post a link to them? Thanks!
Anyways, here's the test class I've been using to try to figure this out in its current iteration. Right now the image I want to load is in src/resources and the class is in src/imagedisplaytest
What's the best way to do this? Also, if anybody has any good resources for learning about the class and/or ClassLoader things could you please post a link to them? Thanks!