Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5950629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:25:14+00:00 2026-05-22T17:25:14+00:00

I have written a server in Java that allows clients connected to it to

  • 0

I have written a server in Java that allows clients connected to it to control the mouse and keyboard of the computer. To do this it uses the java.awt.Robot class.

I need this server to run in the background and start automatically. The first OS I am tackling this problem on is Debian based (Ubuntu 11.04) and a daemon seems like the obvious choice. The problem is that when the daemon is started during boot or during the installation of my debian package (whose postinst script starts it using /etc/init.d/pc-remote-server start) I get this error:

java.awt.AWTException: headless environment
    at java.awt.Robot.<init>(Robot.java:97)
    at com.se.pcremote.server.CommandExecuter.<init>(CommandExecuter.java:72)
    at com.se.pcremote.server.PCRemoteServer.<init>(PCRemoteServer.java:215)
    at com.se.pcremote.server.PCRemoteServer.main(PCRemoteServer.java:122)

Is there any way I can use the java.awt.Robot class from within a daemon process? Could I spawn a secondary process from the daemon process that is not a ‘headless environment’? Or is there a better way for me to get a ‘service’ like result that does not have this limitation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:25:15+00:00Added an answer on May 22, 2026 at 5:25 pm

    Alright, after doing some more research and trying some more options here is what I came up with:

    Can I use java.awt.Robot from within a daemon? No.

    Further down in my question I elaborated a little:

    Is there any way I can use the java.awt.Robot class from within a daemon process? No. As above.

    Could I spawn a secondary process from the daemon process that is not a ‘headless environment’? Not that I could figure out. It was going to be a lot of work if I did do it anyway.

    Or is there a better way for me to get a ‘service’ like result that does not have this limitation? Yes! Use the desktop environment! In my case since I was using Ubuntu the desktop environment was Gnome. Gnome has a Startup Applications feature that runs off .desktop files on a global and per-user basis as described here. They also provide information on the structure of these .desktop files here. I added a .desktop file to /etc/xdg/autostart (the global autostart folder) that ran my Java ‘service’ and it worked like a treat.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a server written in Java that runs as a Windows service (thanks
I have something like a proxy server (written in java) running between my clients
I have a server written to Java to service HTTP requests for various clients.
I have written a server that performs non-blocking IO using the Java NIO API.
We have written clients in different programming languages (Java, .NET/Silverlight, Flash, Javascript) that communicate
Hey all. I have a server written in java using the ServerSocket and Socket
I have a client-server application written in Java using CORBA for the communication. The
I have a piece of server-ish software written in Java to run on Windows
I am trying out GWT in this 'configuration': 1) I have written a server
I have written a custom server control which (pseudo-code) looks like public class MyCustomCtrl

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.