I try to to open a Browser with a URL if a WebServer is called. The WebServer works fine on a Tomcat7 and I created it with Eclipse. I tested this Code on the Eclipse Server and every thing is ok and a new Browser with the URL is open.
public java.lang.String register(java.lang.String username, java.lang.String password) throws java.rmi.RemoteException {
try{
Desktop.getDesktop().browse(new URI("http://google.de"));
}catch(Exception e){
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String exceptionAsString = sw.toString();
username = exceptionAsString;
}
return "NEW TOKEN:"+password + username;
}
But if I deploy the code as a war-file to the "real" TomcatServer I get this error: (the webservice is ok and i become the return value, but the new Browser is not open)
The Error is thrown, because the desktop is not supported Desktop.isDesktopSupported() == false
on the "real" Server
java.awt.HeadlessException at java.awt.Desktop.getDesktop(Desktop.java:124)
....
My question is now, why I get this error when everything works fine on the test system and how could I resolve this problem ?