hello , i am working on my GUI skill and i stumble on a pretty silly problem but well i guess it is not that silly to me, as i am using no IDE , instead a simple dos command to run my program and a notepad to write my classes,and i can't seem to be able to get my code to find my image file and load them can anybody let me know how to set the path?
There was a young man of Cadiz <br />Who inferred that life is what it is , <br />for he early learnt ,<br /> If it were what it weren't ,<br />it could not be that which it is
Let the class loader find the image for you and then have a look at the URL path it comes up with. You can use this to figure out how to write a relative path string that works. The image must be on you class path for the loader to find it. Start with the image in the current directory for ease.
this the method i used to load my images and everytime it is saying " couldn't find the file" and my image file is on the same directory with it, that is why i think it is my classpath the problem than my code..
Joined: Jan 14, 2004
Let's have a look at the path that is being sent to the createImageIcon method. In CelsiusConverter2.java we find it here
The path is images/convert.gif which says that the convert.gif image is in a folder named images. If you want the class loader to look for the image in the current directory, ie, same directory as your .class files, then you would use a path of convert.gif.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com