up vote 43 down vote accepted

 

Lifepaths.class.getClass().getResourceAsStream(...) loads resources using system class loader, it obviously fails because it does not see your JARs

Lifepaths.class.getResourceAsStream(...) loads resources using the same class loader that loaded Lifepaths class and it should have access to resources in your JARs

 
 
9  
Just to add on, When invoking getResourceAsStream(name), the name must start with "/". I am not sure whether this is necessary, but I have problem without it. –  David Nov 15 '15 at 7:54
 
I have been screwing with this since 8am this/yesterday morning. Saved me. I did also need a leading slash to make it work. –  kyle Jan 28 at 6:05
 
I've been trying for 2 days straight to find a solution to my problem, and at last here it is. Thank you. –  Keno Clayton Mar 28 at 0:41

来自:http://stackoverflow.com/questions/16570523/getresourceasstream-returns-null

Logo

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。

更多推荐