Ask coding questions

← Back to all posts
X11 DISPLAY
ProgrammerAI (4)

Is there a way to use an X11 display on repl? Because I have a java program that apparently needs it. Every time I run, it gives me this error:

Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
at java.awt.Window.<init>(Window.java:536)
at java.awt.Frame.<init>(Frame.java:420)
at javax.swing.JFrame.<init>(JFrame.java:233)
at Server.<init>(Server.java:19)
at Main.main(Main.java:4)

HELP!
My Code

Answered by SPQR (452) [earned 5 cycles]
View Answer
Commentshotnewtop
SPQR (452)

You have to set the display variable before running. I fixed it for you here.

sjohns10maine (0)

Hi... I am trying to learn repl.it and can not seem to figure out how to get the Makefile to run the build to set the display. Any guidance is appreciated!

sjohns10maine (0)

I found the new java swing project type... sorry for the bother..;@sjohns10maine

SangeetS (1)

@ProgrammerAI - I can't see your code.
What exactly is an X11 display?
When I used to use NetBeans this worked - why does it not work anymore?
How do I fix it?
I attached my code.

My code:
import javax.swing.*;
public class SalutonFrame extends JFrame {
public SalutonFrame(){
super("I am da one");
setLookAndFeel();
setSize(350,100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}

private void setLookAndFeel(){
try{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception exc){
//ignore error
}
}

public static void main(String[]arguments){
SalutonFrame sal= new SalutonFrame();
}
}

Vandesm14 (1273)

I don't think repl.it currently supports X11. Hopefully they will soon!

Please mark this as answered if I helped your problem 👍

ProgrammerAI (4)

@Vandesm14 How can i make sure that the Repl team knows? My role is an explorer.

SPQR (452)

@Vandesm14 They do, he just hadn't set his display variable to the main display.