I've seen from one of these other threads that you're calling this code from a JSP file (as shown by stack trace element at com.ibm._jsp._Translation._jspService(_Translation .java:158)).
Are you aware that calling this method from a JSP would return the server's screen size, not the client's? You can only get the client screen size from an applet, and that probably still requires a signed applet.
If you really do need to get the server's screen size, add -Djava.awt.headless=false to your JVM options.
Which screen size are you trying to get? That of the client or the server?
If it's the server, does the server even have a screen size to return? If it's a Linux or Unix server without any windowing system (like X11 or Xorg), you will never be able to get the screen size because there simply isn't any.
I have encountered the java.awt.headlessexception when the code I developed moved from Windows environment to AIX environment.
The code snippet is Dimension.getDefaultToolKit().getScreenSize(). Tried a lot in forums. 2 viable options are using System.setProperty() and setting java.awt.headless=true on the console. If you use the former, have to be set even before class loading happens (I felt complicated). The latter is not recommended in enterprise applications (as the web admin has to set it every time the JVM is restarted).
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book