I mainly followed this thread:
How do you add files to a jar using Netbeans 6.5?
I have a class named Card then needs to load a file and return the name of the InputStream.
This is the code to obtain the input:
public String getFilename()
{
String result= "" + seed + "-" + value + ".png";
return result;
}
public InputStream getInputStream()
{
InputStream result;
result= Card.class.getClassLoader().getResourceAsStream(getFilename());
return result;
}
The filename is correct, all the files are in the src folder of the project.
If I try to run it with Netbeans 7.2 it works.But if I build the project and move the jar from it's original position, run it, it doesn't work anymore.It doesn't load the files(result is null).
What could the problem be?