0

I have a client sever java program. The client's work is to capture the screen and send data to server. An additional function it does is opens the website given from server and send some text to server. I wanted the client to run at startup, so I wrote a script and used it in /etc/init.d and used update-rc.d scriptname defaults and then rebooted. On reboot, the text I am supposed to receive works perfectly. But I am not able to browse or receive captured screen from client.

The script I used in init.d is as follows:

#!/bin/sh

### START INIT INFO
# Provides: suscript
# Required-Start:    $remote_fs $syslog $local_fs $network
# Required-Stop:     $remote_fs $syslog $local_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

java -jar /etc/capture/capture.jar

I run the client jar as root. How do I bring the graphical data to the server?

  • "Capture the screen" -> how? And which screen? It goes through a few different forms during boot, and there could also be considered to be more than one in parallel. Do you mean capture the console output? Or taking a screenshot of an X session? Etc. You need to explain in more detail what you are trying to do. – goldilocks Jun 10 '14 at 13:19
  • @goldilocks Java has Rectangle class to capture screenshots, so I am using it to capture the screen which occurs in front of me as desktop. I think most probably we will be using it for screenshot of an X session. – Joker Jun 10 '14 at 13:22
3

Java has Rectangle class to capture screenshots, so I am using it to capture the screen which occurs in front of me as desktop. I think most probably we will be using it for screenshot of an X session.

There may be multiple X sessions (or none), and in any case your process is not associated with any of them, so it is hard to say how it might be considered to have any screen to capture. Just because it is running on a system which has a physical monitor attached does not mean the process is running on the monitor. It's running in the background of the system.

If you have a means of ensuring that the process is running in an X session, you should explain what that is -- it does not happen automagically. Further:

# Required-Start:    $remote_fs $syslog $local_fs $network

None of this includes anything about X, and very likely this service will start before there is any GUI running whatsoever (keeping in mind that a splash screen is just an image, not a GUI). That being the case, the parts of it that require such an interface will fail.

Presuming you are using a display manager, you will want to look at how the init system has scheduled your process in relation to that and set your prerequisites so that it starts after the DM.

  • Thanks for your answer. I know that there will be background process running. I just want to capture whatever is shown in desktop monitor. I think java's Rectangle class will take care of that. I am new to Linux, so I am in a learning curve. Where do I find the details about DM? like what DM I am using. How to work with it etc. – Joker Jun 11 '14 at 4:13
  • I tried # Required-Start: $remote_fs $syslog $local_fs $network $lightdm. But still same results. – Joker Jun 11 '14 at 6:12
  • I tried X-Interactive:true and X-Start-Before: $lightdm but that too did not work. – Joker Jun 13 '14 at 4:41
  • You need to find out why by putting some debugging output into the program itself. Does it start at all? If so, at what point does its execution fail? Does it think it has made a screen grab? If not and you replace it with a simple script that writes to a file, does that work? If so, you can execute from there and check how far things get. – goldilocks Jun 13 '14 at 10:55
  • I tried writing my exception message to a file from my jar. It works normally, no exception occurs. – Joker Jun 24 '14 at 5:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.