 <p>This is, at it has been stated, not the optimal way to load resources, but if you absolutely must have a <code>java.io.File</code> reference, then try following:</p> <pre><code> URL url = null; try { URL baseUrl = YourClass.class.getResource("."); if (baseUrl != null) { url = new URL(baseUrl, "yourfilename.ext"); } else { url = YourClass.class.getResource("yourfilename.ext"); } } catch (MalformedURLException e) { // Do something appropriate } </code></pre> <p>This gives you a <code>java.net.URL</code> and it can be used in a <code>java.io.File</code> constructor.</p>