Installer icon indicating copy to clipboard operation
Installer copied to clipboard

Show help text when ran in headless environment without args

Open PaintNinja opened this issue 1 year ago • 3 comments

Currently the installer crashes if you run it without args in a headless environment. This PR makes it show the help text instead, which is more user-friendly. Also fixed a typo.

PaintNinja avatar May 30 '24 22:05 PaintNinja

Last time we tried this it didn't throw the headless exception and there wasn't a good non erroring way to detect it was headless. But if this works go for it.

LexManos avatar May 31 '24 16:05 LexManos

I found out about the headless exception from a log a user provided in the Discord:

JVM info: Oracle Corporation - 22.0.1 - 22.0.1+8-16
java.net.preferIPv4Stack=true
Current Time: 30/05/2024 22:18:59
Host: files.minecraftforge.net [104.21.58.163, 172.67.161.211]
Host: maven.minecraftforge.net [172.67.161.211, 104.21.58.163]
Host: libraries.minecraft.net [13.107.246.42]
Host: launchermeta.mojang.com [13.107.246.42]
Host: piston-meta.mojang.com [13.107.246.42]
Host: sessionserver.mojang.com [13.107.246.42]
Host: authserver.mojang.com [Unknown]
Data kindly mirrored by CreeperHost at https://www.creeperhost.net/
java.awt.HeadlessException:
No X11 DISPLAY variable was set,
or no headful library support was found,
but this program performed an operation which requires it,
        at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:166)
        at java.desktop/java.awt.Window.init(Window.java:501)
        at java.desktop/java.awt.Window.<init>(Window.java:453)
        at java.desktop/java.awt.Window.<init>(Window.java:608)
        at java.desktop/java.awt.Dialog.<init>(Dialog.java:674)
        at java.desktop/java.awt.Dialog.<init>(Dialog.java:519)
        at java.desktop/javax.swing.JDialog.<init>(JDialog.java:426)
        at java.desktop/javax.swing.JOptionPane.createDialog(JOptionPane.java:957)
        at net.minecraftforge.installer.InstallerPanel.run(InstallerPanel.java:258)
        at net.minecraftforge.installer.SimpleInstaller.launchGui(SimpleInstaller.java:182)
        at net.minecraftforge.installer.SimpleInstaller.main(SimpleInstaller.java:154)
Exception in thread "main"
java.awt.HeadlessException:
No X11 DISPLAY variable was set,
or no headful library support was found,
but this program performed an operation which requires it,
        at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:166)
        at java.desktop/java.awt.Window.<init>(Window.java:553)
        at java.desktop/java.awt.Frame.<init>(Frame.java:428)
        at java.desktop/java.awt.Frame.<init>(Frame.java:393)
        at java.desktop/javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1925)
        at java.desktop/javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:2001)
        at java.desktop/javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1696)
        at java.desktop/javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:875)
        at java.desktop/javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:677)
        at java.desktop/javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:648)
        at net.minecraftforge.installer.SimpleInstaller.launchGui(SimpleInstaller.java:185)
        at net.minecraftforge.installer.SimpleInstaller.main(SimpleInstaller.java:154)

So maybe they fixed it not throwing or it only throws sometimes? Dunno ¯\_ (ツ)_/¯

PaintNinja avatar May 31 '24 19:05 PaintNinja

Maybe, java does a lot of changes. As long as this doesn't bump the required java (it shouldn't iirc that exception is from java 1.4) then I'm fine with it.

LexManos avatar Jun 01 '24 08:06 LexManos

The code looks fine. After lunch I'll run it on my private home server and if it works I'll give the thumbs up.

Jonathing avatar Mar 04 '25 17:03 Jonathing