3

Android build upon a Linux kernel and most Linux systems use a desktop environment like GNOME, KDE, LXDE etc.

I have compiled Linux kernel and minimal root file system build with busybox, arm cross compiler tool-chain and arm-J2SE. Currently I have the basic Command Line Interface. Now I want to use a desktop environment (enable mouse and handle mouse or touchscreen inputs/events). Because my java command line codes running fine but when I am using swing or awt application it shows this exception.

Exception in thread "main" java.awt.HeadlessException at
         java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207)
at java.awt.Window.<init>(Window.java:535)
at java.awt.Frame.<init>(Frame.java:420)
at javax.swing.JFrame.<init>(JFrame.java:224)
at Gui.main(Gui.java:7)

Just I have a look on javadoc and It shows,

public class HeadlessException
        extends UnsupportedOperationException

Thrown when code that is dependent on a keyboard, display, or mouse is called in an environment that does not support a keyboard, display, or mouse.

Basically it need some window management or GUI like environment. I found few library for building a GUI environment like XLIB/X11,SDL which can manage those mouse and touch screen events. Can any one tell me where to start to achieve my goal. Few Linux system use startx command to enable GUI environment then brought the desktop,window,mouse etc. I need some thing like this to run my java gui applications. Could any one lead me a way.

Shantanu Banerjee
  • 1,417
  • 6
  • 31
  • 51

2 Answers2

2

I know every Linux system should have a desktop environment like GNOME, KDE, LXDE etc.

That's wrong. Consider a server or an embedded system (not a smartphone), why it should require a UI? An OS kernel doesn't have to provide a GUI.

Below is the Android architecture / layers of libraries, and there Surface Manager + Window Manager + View System is Android's desktop environment.

enter image description here

For more information on Linux and graphics systems check this SO question.

For your Java exception, you are using a headless Java environment and trying to use Swing/AWT which is by definition of headless Java environment is not supported.

How can I setup a GUI environment that supports mouse,keyboard or other inputs?

You are trying to port Android to your device, which if your device doesn't have an already ongoing Android port effort, requires deep knowledge of peripherals it has as well as Android system in general. Information for these are vastly available on the net, however it is not a trivial task.

Community
  • 1
  • 1
auselen
  • 27,577
  • 7
  • 73
  • 114
0

First, a Linux distro does not NEED to have a GUI. Or as you must say - X Window System.

Can anyone tell me which desktop environment is used by the Android?

None. Android does not use X.

Should I have to implement Desktop Environment for supporting keyboard and mouse?

I have no idea. I do not know what you are trying to achieve. If you want to see whether your program would work in Android, please take a look at the Android SDK. You may want to look at the Android emulator and write your code keeping the SDK in mind.

Aditya K
  • 487
  • 3
  • 11