PDA

View Full Version : java.awt.HeadlessException and then java.lang.InternalError



Albretch
07-07-2007, 07:38 PM
I am unsuccessfully trying to run a very simple java applet that is giving me java Exceptions and Errors
~
The thing is that I would like to be able to edit and run the JApplet in the console Window that lets me copy and paste errors dumped on the screen
~
or how could you copy some text off the screen and paste onto a document opened using kate
~
import javax.swing.JFileChooser;
import javax.swing.JApplet;

public class FileChooserTest00 extends JApplet{
// __
public void init(){ JFileChooser fileChooser = new JFileChooser(); }
// __
public static void main(String[] args){
FileChooserTest00 fileChooserTest = new FileChooserTest00();
fileChooserTest.init();
}
}

root@Knoppix:/home/root# appletviewer FileChooserTest00.html
~
Warning: Can't read AppletViewer properties file: /root/.hotjava/properties Using defaults.
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(Graphic sEnvironment.java:159)
at java.awt.Window.<init>(Window.java:317)
at java.awt.Frame.<init>(Frame.java:419)
at java.awt.Frame.<init>(Frame.java:384)
at sun.applet.AppletViewer.<init>(AppletViewer.java:141)
at sun.applet.StdAppletViewerFactory.createAppletView er(AppletViewer.java:82)
at sun.applet.AppletViewer.parse(AppletViewer.java:11 22)
at sun.applet.AppletViewer.parse(AppletViewer.java:10 56)
at sun.applet.Main.run(Main.java:138)
at sun.applet.Main.main(Main.java:80)
~
// __
root@Knoppix:/home/root# DISPLAY=:0.0
root@Knoppix:/home/root# export DISPLAY
root@Knoppix:/home/root# echo $DISPLAY
:0.0
root@Knoppix:/home/root# appletviewer FileChooserTest00.html
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified

Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$000(X11Graph icsEnvironment.java:53)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEn vironment.java:142)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvir onment(GraphicsEnvironment.java:68)
at java.awt.Window.init(Window.java:270)
at java.awt.Window.<init>(Window.java:318)
at java.awt.Frame.<init>(Frame.java:419)
at java.awt.Frame.<init>(Frame.java:384)
at sun.applet.AppletViewer.<init>(AppletViewer.java:141)
at sun.applet.StdAppletViewerFactory.createAppletView er(AppletViewer.java:82)
at sun.applet.AppletViewer.parse(AppletViewer.java:11 22)
at sun.applet.AppletViewer.parse(AppletViewer.java:10 56)
at sun.applet.Main.run(Main.java:138)
at sun.applet.Main.main(Main.java:80)
~

kirol
07-07-2007, 10:45 PM
root@Knoppix:/home/root# appletviewer FileChooserTest00.html
~
Warning: Can't read AppletViewer properties file: /root/.hotjava/properties Using defaults.
Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
Why are you running this as root? Simply run it from a konsole, as user "knoppix".
If you need root privilege, issue "xhost +" from a knoppix session, to allow other accounts to use the X display.
You also need to have the variable DISPLAY defined, "export DISPLAY=:0" shoudl do (but is unnecessary for user "knoppix").