LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Java | Ubuntu 8.04 | java.awt.HeadlessException (https://www.linuxquestions.org/questions/linux-newbie-8/java-%7C-ubuntu-8-04-%7C-java-awt-headlessexception-695080/)

akuma_linux 01-05-2009 05:59 AM

Java | Ubuntu 8.04 | java.awt.HeadlessException
 
Hello

I have an Ubuntu 8.04 machine running tomcat 5.5, and a java application which is showing an error :

Code:

An error occurred:

      java.awt.HeadlessException

This error only occurs on one page of the java app, the rest works fine.

Gnome / Xserver is installed and the DISPLAY variable is set to localhost:0.

My Questions are as follows -

1 - With this error, does it mean java is running in headless mode? If so, should headless mode not be set to false since a full graphical desktop environment is present?

2 - How do I actually change this 'headless' mode of java to false?

The version of java installed is below :
Code:

java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

Any advice is welcome, thankyou.

TB0ne 01-05-2009 08:38 AM

Quote:

Originally Posted by akuma_linux (Post 3397680)
Hello

I have an Ubuntu 8.04 machine running tomcat 5.5, and a java application which is showing an error :

Code:

An error occurred:

      java.awt.HeadlessException

This error only occurs on one page of the java app, the rest works fine.

Any advice is welcome, thankyou.

Well, I'm not a big Java guru, but it seems to me that if you're only getting an error on ONE PAGE of your app, there's a problem with the code for that one page, not with Java/Tomcat in general. If there was a problem there, things would go wrong with other pages too....

Have you checked the Tomcat logs?

Mega Man X 01-05-2009 08:58 AM

Quote:

Originally Posted by akuma_linux (Post 3397680)
Hello

I have an Ubuntu 8.04 machine running tomcat 5.5, and a java application which is showing an error :

Code:

An error occurred:

      java.awt.HeadlessException

This error only occurs on one page of the java app, the rest works fine.

Gnome / Xserver is installed and the DISPLAY variable is set to localhost:0.

My Questions are as follows -

1 - With this error, does it mean java is running in headless mode? If so, should headless mode not be set to false since a full graphical desktop environment is present?

2 - How do I actually change this 'headless' mode of java to false?

The version of java installed is below :
Code:

java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

Any advice is welcome, thankyou.

That exception is thrown when you make a call to some device (keyboard, mouse, display etc) in a place where those are not available. This code will crash:

Code:

import javax.swing.JOptionPane;

public class MainClass {

        public static void main(String[] args) {
                System.setProperty("java.awt.headless", "true");
                JOptionPane.showMessageDialog(null, "Testing");
        }
}

1 - With this error, does it mean java is running in headless mode? If so, should headless mode not be set to false since a full graphical desktop environment is present?

Nope. If you are manually setting your code to headless, as I did above, it will crash. You could make a check to see if the environment is Headless before setting the properties

2 - How do I actually change this 'headless' mode of java to false?
Check my suggestion above.

Since you said you only get that exception in one part of the program, check what it is doing at that moment. Time to set some breakpoints maybe? :)

Off-topic note: I love to play with Akuma. Don't particularly like playing against him though :)

akuma_linux 01-06-2009 10:27 AM

Thanks for the replies.

I await a reply from the author of the Java app (my role in this was to set up the server to host this app, my knowledge of java coding is poor).

I'll post back if we get it working.

Off-topic note :Good taste Mega Man X, can't wait for sf4! :)


All times are GMT -5. The time now is 10:17 PM.