I';我试图在java上创建一个映像,但它赢了';t载荷

I';我试图在java上创建一个映像,但它赢了';t载荷,java,Java,我试图为我的游戏创建图像,但由于某些原因图像无法加载。有人能帮我吗 下面是图像加载器类代码 package gold; import java.awt.image.BufferedImage; import java.io.IOException; import javax.imageio.ImageIO; public class ImageLoader { public static BufferedImage LoadImage(String path) {

我试图为我的游戏创建图像,但由于某些原因图像无法加载。有人能帮我吗

下面是图像加载器类代码

package gold;

import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;

public class ImageLoader 
{
    public static BufferedImage LoadImage(String path)
    {
        try {
            return ImageIO.read(ImageLoader.class.getResource(path));
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
        return null;
    }
这个类的其余部分应该加载图像,但由于某些原因不会加载

package gold;

import java.awt.Graphics;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
public class Game implements Runnable
{
    private Thread thread;
    private Display display;
    public int width, height; 
    private boolean running = false;
    public String title; 
    private BufferStrategy buf;
    private Graphics d;
    private BufferedImage testImage;
    public Game(String title, int width, int height)
    {
        this.width = width; 
        this.height = height; 
        this.title = title;
        display = new Display(title, width, height);
    }
    private void init()
    {
        display = new Display(title, width, height);
        testImage = ImageLoader.LoadImage("/textures/download.jpg");

    }
    private void tick()
    {

    }
    private void render()
    {
        buf = display.getCanvas().getBufferStrategy();
        if(buf==null)
        {
            display.getCanvas().createBufferStrategy(2);
            return;
        }
        d = buf.getDrawGraphics();
        d.clearRect(0,0, width, height);
        //draw here
        d.drawImage(testImage, 20, 20, null);
        //end Drawing
        buf.show();
        d.dispose();
    }
    public void run()
    {
        init();
        while(running)
        {
            tick();
            render();
        }   

    stop();
    }
    public synchronized void start()
    {
        if(running=true)
            return;
        running = true;
        thread = new Thread(this);
        thread.start();
    }
    public synchronized void stop()
    {
    if(!running)
        return;
    running = false;
    try
    {
        thread.join();
    }catch(InterruptedException e)
    {
        e.printStackTrace();
    }
    }

}

您是否获得任何日志输出?您所说的日志输出是什么意思?您是否尝试使用JPG映像的完整路径?不,我没有在IDE中使用完整路径有一个控制台,其中显示
println
e.printStackTrace()
调用。也许你可以从中得到更多的信息。