简体   繁体   English

我切换到Linux,现在得到了java.awt.HeadlessException

[英]I switched to Linux and now I get a java.awt.HeadlessException

I am making a 2D game engine using the core java library, and just switched to linux. 我正在使用核心Java库制作2D游戏引擎,并且刚切换到Linux。 Before my game engine would run fine, but now that I've switched to linux, when I try to run the code, it throws a java.awt.HeadlessException. 在我的游戏引擎无法正常运行之前,但是现在我已切换到linux,当我尝试运行代码时,它将引发java.awt.HeadlessException.

How can i fix this? 我怎样才能解决这个问题?

This is the class that throws the error. 这是引发错误的类。 I'm not sure how much it's gonna help though. 我不确定这有多大帮助。 There's a lot more to it. 还有很多。 I'm pretty sure the only important thing is that I use the awt library for keyevents. 我敢肯定,唯一重要的是我将awt库用于关键事件。

package Platformer;

import java.awt.Dimension;

import javax.swing.JFrame;

public class Game {
    public static void main(String args[]){
        JFrame frame=new JFrame();
        GameComponent gp=new MainGame();
        frame.add(gp);
        frame.pack();
        frame.setSize(1920, 1080);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

The exception says that the JRE which is installed in that linux machine might not contain headless JRE. 异常表明,安装在该Linux计算机上的JRE可能不包含无头JRE。

Headless JRE are the package which provides dependencies used for the graphical components. 无头JRE是提供用于图形组件的依赖项的软件包。

Check your Java installation, if in doubt, try reinstalling 检查您的Java安装,如有疑问,请尝试重新安装

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM