在使用Java Web Start时,有一些资源如图片、class="tags" href="/tags/PROPERTIES.html" title=properties>properties文件等,不能得到更新。需要将这些文件打包成jar文件,这样才能通过jws更新和运行。
一.使用class="tags" href="/tags/LOG4J.html" title=log4j>log4j.class="tags" href="/tags/PROPERTIES.html" title=properties>properties,打包后,通过下面的语句:
URL class="tags" href="/tags/URL.html" title=url>url = getClass().getResource("prop/class="tags" href="/tags/LOG4J.html" title=log4j>log4j.class="tags" href="/tags/PROPERTIES.html" title=properties>properties");
PropertyConfigurator.configure(class="tags" href="/tags/URL.html" title=url>url);
使用Log4j。
例如:
Class c;
Logger log = Logger.getLogger(c.getName());
class="tags" href="/tags/URL.html" title=url>url = c.getResource("/com/wonder/conf/class="tags" href="/tags/LOG4J.html" title=log4j>log4j.class="tags" href="/tags/PROPERTIES.html" title=properties>properties");
PropertyConfigurator.configure(class="tags" href="/tags/URL.html" title=url>url);
log.debug("Test");
二.使用图片等资源。通过下面的语句完成
Icon icon = new ImageIcon(getClass().getClassLoader().getResource("images/save.gif"));