0

I am trying to install Tn5250J emulator in ubuntu machine. I have JDK 8 is already installed on machine. Whenever i try to run the installer jar in ubuntu it gives following error.

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11.XToolkit

To solve it, I set DISPLAY variable, after that i am getting following exception

Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using 'localhost:0.0' as the value of the DISPLAY variable.
        at java.desktop/sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
        at java.desktop/sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:102)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.desktop/sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:61)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:315)
        at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:101)
        at java.desktop/java.awt.GraphicsEnvironment$LocalGE.<clinit>(GraphicsEnvironment.java:83)
        at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:129)
        at java.desktop/sun.awt.X11.XToolkit.<clinit>(XToolkit.java:231)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:315)
        at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:588)
        at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:583)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:582)
        at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:198)
        at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:217)
        at org.tn5250j.tools.GUIGraphicsUtils.createImageIcon(Unknown Source)
        at org.tn5250j.gui.TN5250jSplashScreen.<init>(Unknown Source)
        at org.tn5250j.My5250.<init>(Unknown Source)
        at org.tn5250j.My5250.main(Unknown Source)

I checked TN5250J official site for installation,They have given only one command, the same i am following but getting above errors. Please let me know how i can resolve the above issue and install TN5250J emulator successfully in ubuntu.

Abra
  • 19,142
  • 7
  • 29
  • 41
Ankita
  • 1
  • Your java installation may be _headless_. Perhaps this question will help. [How to detect if a graphical interface is supported?](https://stackoverflow.com/questions/4245198/how-to-detect-if-a-graphical-interface-is-supported) – Abra Aug 02 '21 at 06:20
  • Thanks for reply, Could you please tell me how i can check whether installed java is headless or not? If you have any jdk installation link with graphical support , please share – Ankita Aug 02 '21 at 11:32
  • Did you read the question I linked to? The accepted answer shows how to do it in java code: static method `isHeadless()` in class `GraphicsEnvironment`. – Abra Aug 02 '21 at 11:55
  • Yes went through the link..it tells about windows, i need to know in ubuntu..i tried openjdk 8 and 11 both...but same error i am getting – Ankita Aug 02 '21 at 12:27
  • I want to install JDK GUI version not the headless one – Ankita Aug 02 '21 at 12:38
  • I checked with below code whether it is headless or GUI enabled, it prints me with GUI means installed jdk is not headless.........import java.awt.GraphicsEnvironment; public class SampleJava { public static void main(String[] args) { if (GraphicsEnvironment.isHeadless()) { System.out.println("Print it is headless"); } else { System.out.println("Print it is with GUI"); } } } – Ankita Aug 02 '21 at 13:08

0 Answers0