В настоящее время мы пишем код в Visual Studio Code и подключены к кодовому пространству Github. У нас есть файл Main.java и следующий код внутри него:
Код: Выделить всё
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferStrategy;
import javax.swing.*;
public class Main extends Canvas implements KeyListener {
public Main() {
JFrame frame = new JFrame("ma pona");
frame.add(this);
frame.setSize(1000, 750);
frame.getContentPane().setBackground(Color.DARK_GRAY);
frame.setVisible(true);
frame.setResizable(false);
frame.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public static void main(String[] args) throws Exception {
new Main();
}
Код: Выделить всё
Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:208)
at java.desktop/java.awt.Window.(Window.java:548)
at java.desktop/java.awt.Frame.(Frame.java:423)
at java.desktop/javax.swing.JFrame.(JFrame.java:224)
at Main.(Main.java:8)
at Main.main(Main.java:22)
Подробнее здесь: https://stackoverflow.com/questions/783 ... on-which-r