我在Eclipse项目的文件夹中有一个图像文件,用于存储图像文件(logo.jpg).但是我不知道如何在我的主程序中访问它.
我曾尝试过以下方法
private static URL logoPath
public class MainApplication
{
public void createGui()
{
logoPath.getClass().getResource("/Resources/images/logo.jpg");
////
}
/////
}
Run Code Online (Sandbox Code Playgroud)
问题是我一直得到一个空指针异常,所以很明显路径做错了,否则logoPath.getClass()就会绊倒它.
有任何想法吗?