Remote access to Java Swing application screen with interaction - java

Does anyone know if there's a way to provide remote access from a client to a Swing application running on a server? This question also involves how to redirect the screen output on the remote server to a file or process, as it may be a headless environment.
What I want roughly is this:
the user on the client starts up an application on the server
the application's screen output is routed to 'something' which sends it over to the client
the user on the client can tap on the screen indicating mouse clicks and can optionally bring up a keyboard for keyboard input (obviously keyboard will only work if the user previously focused something on the remote app
(I'm especially interested in doing this using iOS as client platform.)

Related

About a chat client-server program in java

I made a client-server chat that uses a postgresql database to store the users. The server uses comunication protocols designed by me to allow the comunication process and everything works fine. The problem is, the user needs to click on a button in order to open the chat window when he gets the message, otherwise he can't read the incoming message. I would like to program a msn-like service where a window opens when you get a message if the window is not already open and if it's open just show the message in that same window. I can't seem to find a way to do it and any help I can get would really be apreciated. Thanks.
A couple of things you may want to take a look at. First is Java integration with Windows System tray.
http://docs.oracle.com/javase/tutorial/uiswing/misc/systemtray.html
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/systemtray/
The other is to run a "listener" in the background perhaps as a Windows service.
This service listens for messages and pops them into a window. The window can be dismissed (hidden) without stopping the service. http://edn.embarcadero.com/article/32068

Java: Control browser through Process

I'm remote controlling a Java application on a PC through an Android phone, and I needed my application to open a browser at the phones command, chrome in this case. I created a "Process" for chrome, opening a certain address. However, I need to be able to give tools on the Android phone for controlling the web page, such as scrolling. Can I programmatically send a command for chrome to scroll from my PC application containing the Process?
Sorry, it may have been unclear, but the only connection the android phone has to the program is through a socket. It is only used as a remote control for another Java application on a PC, which has its own screen.
I do not think that clean solution exists.
But I can suggest the following directions:
(1) try to investigate the native chrome API. If it has such ability call it with JNI.
(2) Try to use class java.awt.Robot. It allows to simulate user's activity, e.g. mouse clicks. Unfortunately it does not allow you to find any window outside your application, so it is a problem to decide where to perform the click.
(3) You can create proxy server and make browser you open to go to the target URL through the proxy. The proxy server will insert into the page your javascript that will communicate with server. The application that opens browser will send commands to server. The javascript that you inserted will receive these commands using AJAX and perform them. JavaScript can scroll browser window, so theoretically you can implement this.
If you can target the tab you want to control and edit the address bar you could send the command 'javascript:scrollTo(x, y)'. I just tested it on this page and it seems to work fine, replacing what I typed with the original address of the page.
Can I programmatically send a command for chrome to scroll from my PC
application containing the Process?
Not directly. What you could do is make some sort of web service that sits between the Android client and page that the Android client can send commands to and the page can periodically poll via AJAX calls to see what the client wants. That would be a clean DIY way that would work on other browsers besides Chrome.
You can use vnc viewer applications for that.
http://code.google.com/p/android-vnc-viewer/

Run Java AWT/Swing GUI app in headless server

I have a gateway application that comes up with a login dialog and then a GUI window. I will be running this app on a co-located server without a display. I need to interact with the dialog only when logging in and perhaps to check out the main GUI occasionally. The server is Debian 5.0.
The only ideas I have so far are:
Tunnel an X session to my desktop for logging in but I'm not sure what will happen if the X session disconnected (ie, I reboot my desktop, etc..)
Try to instantiate/launch the app from a wrapper Java application that can hopefully fill out the login dialog or login directly however I would most likely lose the ability to see the main GUI this way and other side effects might occur.
It's too bad this particular app was written in Swing and doesn't provide a command-line only mode or daemon mode.
You can run a VNC server on the machine where the application runs. Then you can connect to the virtual X-server at any time to interact with the user interface.
I don't have a Debian system nearby, but on Ubuntu there is a package vnc4server that provides the features you need.

Java App on Mac asking for allow network connections everytime

My Java.app broadcasts a packet on the network as soon as it starts up. Everytime I start this app, the Mac asks me do I want to allow network connections blah..blah.. Can I use info.plist or something to allow network access to this app and not bother the user who has trustingly downloaded and installed my app.
Thanks
You can choose to allow incoming connections for specific services in System Preferences > Security > Firewall.
Addendum: You application will appear only if the user has chosen to "Set access for specific services and applications." It will be added the first time the application attempts to open the port.
Addendum: The application appears with the name java in the Firewall pane. Once the user chooses to accept or deny, the dialog ceases to appear. This simple example is convenient for testing.
If you codesign your app (using the same key across updates) it should work properly with the app-specific firewall on. It seems to be a bug on Apple's side that unsigned java apps are prompted for allowing network connections (even if they don't try to listen to the network) every time they are run.

How to detect user activity with a Java service running on Windows?

My goal is to create a system monitoring application using Java. I would like to know when a user is doing activity on a Windows PC. The result would be something like this:
8:00 - 8:15 activity
9:12 - 10:29 activity
12:24 - 15:34 activity
I'm not interested in any other information (which key was pressed, application used, etc.). Only user activity.
Is this even possible in Java? I plan to run my java application as a service. But as for getting events when a user uses the computer, I have no idea where to start.
[Edit] Further clarifications: I'm not interested in the details of the activity, only that a user has moved the mouse or pressed a key. I don't care which key was pressed, as long as I know that a key was pressed in an application somewhere. I also don't care for any other activity except key pressed and mouse movement (for example, I am not interested if a USB key is inserted in a USB port).
You cannot monitor user activity directly from a service. The service will be running in a different window station from the users activities and so will have no way to hook into that activity (except through filter drivers that would need to be written in C).
So you will need a client application that runs in the user's desktop and hooks into the keyboard and mouse activity. You would do that via two calls to the Windows API SetWindowsHookEx (for low level keyboard and mouse hooks) using JNI. To monitor activity the application would then need to process the keyboard and mouse hooks for messages.
You could launch the application as auto-start by adding an entry to the registry's Run key or you could have your service monitor for session log on events and launch the application from it. Then the user session application could either process the information itself or pass it to the service via a pipe or socket.
What exactly do you mean by 'user activity'? You need to define that term precisely first to even start thinking of a solution, especially as you say that "key pressed, application used, etc." are not activities.
You could try this SWT Win32 Extension. It allows you to set keyboard and mouse hooks from java on windows.
This is not directly supported by the java platform
It would be a lot easier if you explore a .NET alternative.
Search for Capture global user input in .net

Categories