Run Java AWT/Swing GUI app in headless server - java

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.

Related

make an interactive windows service

I want my Java application to be an interactive windows service (a windows service that has GUI when the user is logged in).
I searched for this and I see that the way to do it is to have 2 programs, 1st is a service, 2nd is a GUI program and make them communicate - the service will get commands from the GUI program.
Just before I started to split my program, I noticed that in "Java Service Wrapper" there is a flag:
wrapper.ntservice.interactive=TRUE
Is this flag an automatic way to do the same as the following manual config?
administrative tools -> services -> right click -> properties -> under
Log On tab check allow to interact with desktop
Is this way problematic? Should I go for the long way and split my program into two programs (GUI and service)?
thanks
Prior to Windows Vista, all services and application were run in the same session. This provided the convenience of allowing Windows services to have front-facing UIs and interacting with users directly, but it also posed a security risk. For example, a Windows service that runs with elevated user privileges (e.g., admin rights) could potentially be compromised through exploits of the UI.
Beginning with Windows Vista, Windows services are isolated in Session 0 while all user logins and applications are run in other sessions. Technically, Windows services can still interact with the desktop via Session 0, but ordinary users have no convenient way of accessing Session 0. So while your Windows service can pop up a confirmation dialog box, the user will never see it because it displays in the Session 0 desktop. Further, the user will be unable to confirm the dialog, meaning that the Windows service remains "stuck."
In short, having your Windows service interact with the desktop is no longer feasible. You'll have to create the Windows service and then a front-end application and provide some means for them to communicate, e.g., pipes, sockets, shared memory, etc. The recommended way to do this in .NET is to use the Windows Communication Foundation (WCF). I'm not sure how easy this is to do w/ Java, and in the spirit of full disclosure, I use sockets myself.
HTH

Remote access to Java Swing application screen with interaction

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.)

jenkins job not triggering commands and performing ui validations in the targeted machine

I configured a job for doing GUIAutomation(which got developed using java code including running commands and keyboard events) in the targeted machine.
Extra Info:-
I am running a command to launch the installer(installer GUI should come).....but its not happening
When I got any error I am capturing a image using JAVA DefaultToolkit API, but very time its coming as Black, nothing there to watch.
GUIAutomation tool was developed by myself.
Please help me to overcome this problem, since I have to automate it through jenkins.
Usually, problems running GUI programs in Jenkins occur because of the Jenkins service not having privileges to access the display of the slave (or master, you don't mention which) that is running the job. A typical solution is to start the slave via JNLP, which requires logging on to the slave, navigating to the slave's page on the jenkins master (via browser on the slave) and launching the slave process via the button on that page. You can also launch using the javaws command which will be shown on the same page.
On Windows slaves running as a service, you may have success by configuring the service to run as a user with login and desktop privileges for the slave - the default is the Local System user which has no such rights.
I have done the same job as you.
You have to create the jnlp connection. I create one batch file in slave machine such as: jar -jar slave.jar -jnlpurl (your url)/slave-agent.jnlp
If it's remote slave, it's better to use VNC instead of remote desktop when you operate that machine. Because when you close the session, remote desktop will hold the session, so the screenshot would be black.

Hardware support from a web application

I have a web application running with support for some specific pieces of hardware. This is achieved in the following steps:
User runs a small installer that places java files (and a couple
others) on the client machine. The main piece is a jar called "hardwareManager"
User visits web app. The web app runs a java applet which, due to
a .java.policy file placed during the install, has permission to
interact with the client machine outside the browser sandbox.
The applet checks to make sure the hardwareManager is running,
and if not runs a command to start it.
User interacts with the web app which sends commands to the applet via
javascript. The applet then writes commands to a text file
on the client machine. The text file is constantly monitored by the
hardwareManager which runs any commands it reads in.
This works, but seems clunky. I have a couple ideas on how to improve it, but I don't know which, if any, are even worth trying.
Would it be better to set up the hardwareManager as a socketServer and have the applet connect directly to it, rather than going through text files? Is that even possible?
Is there a way to eliminate the applet altogether and have the javascript talk directly to the hardwareManager? Maybe by writing the hardwareManager to be a local http server? What port should it run on? Do javascript xss limitations fit in here somewhere?
It would be less clunky to start the Java application using Java Web Start. This would remove the need to daemonize or install the Java hardware manager.
Another alternative is to use a built-in browser inside Java. I supose this is not an option, since you depend heavily on Javascript (I suppose to provide a rich client experience).
If you already have to install something on the client machine, why did you make the choice to go with a web application?
Talking from experience: We had a Java EE application which needed to print to PoS printers at the client site. We installed a small "synchronizer" application that connects through SSH and synchronizes all clients files. Afterwards, it loads the JAR and executes the program. This program connects through RMI with the server and subscribes to a JMS queue to receive the print assignments.
Applied to your case: Why not let your Java application connect to the server directly? You can use HTTP, SOAP or even JMS over RMI. You can then launch the hardware command from the server (instead of from the limited JavaScript webbrowser environment). This way, you get tons of features: authentication, buffering of commands, and you can even share hardware between multiple clients.
Schematic:
<----AJAX------> Web browser
ApplicationServer
<---HTTP/SOAP--> Java hardware manager application
You can launch the Java application using Java Web Start, which allows you to update the application automatically (instead of needing to pass every client a new installer).

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.

Categories