I am wondering why the method getResourcekeeps returning null, I have the following setting:
getResource
null
public static URL getResource(String path){ URL url = ResourceLoader.class.getResource(path); if (Parameters.DEBUG){ System.out.println(path); } return url; }
My project structure in Eclipse is as follows:
-- res -- img
The variable pathpassed to getResourceis "/res/img"either or "/res/img/smile.png". However, the method continues to return nulland is urlnot set. I also followed the instructions of this question , which were to add the folder to the project class path through the launch configurations, still without success ... Does anyone know what I'm doing wrong?
path
"/res/img"
"/res/img/smile.png"
url
: "/img/smile.png".
"/img/smile.png"
, , , /, Class.getResource, .
/
, res classpath. , Class.getResource , . res.
res
, , res/res/img/smile.png. (), null.
res/res/img/smile.png
http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getResource(java.lang.String)
, , . . , ClassLoader.getSystemResource(java.lang.String). :'/' ('\ u002f'), - , '/'.: modified_package_name/name modified_package_name '/' '.' ( '\ U002e').
, , . . , ClassLoader.getSystemResource(java.lang.String). :
'/' ('\ u002f'), - , '/'.
: modified_package_name/name modified_package_name '/' '.' ( '\ U002e').