Java service wrapper to create service for Java UI application - java

I have created a Java application which needs to run as a service. For service wrapper I tried using tanuki and other wrapper softwares.
Now, my application does run as a service - however, it runs as a service under SYSTEM and not under currently logged in user.
My application has a UI, which does not show when the application is running as a service. I doubt that this has happened because the service is running under SYSTEM and not under currently logged in user.
When I run the application (without installing it as a service), the UI does show up and I could see the java process running under the current user's id, whereas it runs under SYSTEM when installed as a service.
Now, there is nothing to my application if there is no UI. I need to application to run as a service when the system boots up and the UI needs to show up as well.
Has anyone tried to do what I am doing here and has faced a similar issue. If so, how did you go about resolving it?
Is there a different wrapper service that I could use and not have this issue.
Tanuki's documentation does explain setting a java application as a service, but does not talk about a java applicaiton with a UI and running it under the currently logged in user.
Update
Just so that folks here could get a bit more idea as to what is it that I am trying to accomplish - the behavior that I am trying to have with my app is similar to how Dropbox or Yahoo Messenger or any other software has which starts with Windows boot and continues to run in the background, allowing the users to interact with it using the system tray icon. So basically all of this has been built in Java/Swing. Now when it has come to deployment of the app - I can run it standalone but running the jar file or by creating and running an executable wrapper for it. However, I want the software to start with Windows boot and continue to run as a service in the background, while allowing the user to make changes and interact with it via lets say bringing up the UI from a system tray icon that it sets.
As of now, it does run as a service successfully. It performs all the actions that it ideally should - there just is no system tray icon to bring up the UI and make changes to its configuration.
Update - 2
Ok.. I tried advanced installer and it does wrap up everything for me to generate an exe installer for windows. Now all I need is to auto-start the software. Can anyone help me with this? I don't see an option in Advanced installer to automatically have the program add itself up in the auto-start.
Link to tanuki's doc http://wrapper.tanukisoftware.com/doc/english/faq.html

Rohan,
Please take a look at the following page:
http://wrapper.tanukisoftware.com/doc/english/prop-ntservice-interactive.html
You will need to mark the Service as interactive and then run as the SYSTEM user in order to get your GUI to show up on the first logged in desktop.
The problem is that Microsoft changed what services are allowed to do starting with Windows 2008 and Vista. This means that starting with these versions, the GUI will always show up on a sandboxed desktop which the user will need to switch over to.
If you want to show a GUI on all desktops, in all versions of Windows, you will need to run the JVM within the desktop.
Cheers,
Leif

I wanted to comment on your question, but I don't have enough reputation to do it. So I'm misusing the answer function now.
I have a similar problem. I used the tanuki wrapper for a while now on a Windows XP machine and the Swing GUI was shown to all users who logged in.
Now I migrated to Windows 2008 Server and configured the current version of the tanuki wrapper like this:
wrapper.ntservice.interactive=true
wrapper.ntservice.hide_console=true
(see documentation here and here)
The Windows service runs under the LOCAL SYSTEM account.
But the GUI is still not shown. Did you find any solution to the problem?

Don't think you should have a UI with a service. Put it in the startup group instead ?
What's does the UI and application do?

Related

Execute a jar file ever Windows initialize and after the user logon (Not as a Service) that call a process with a GUI

I have a jar file and I wanted to run this file as a service. When this .jar executes, it opens another program that I want to be able to see it GUI. But note: only the second program needs a GUI (the .jar not). I open this second program using the following:
ProcessBuilder processBuilder = new ProcessBuilder(cmdCommand);
processBuilder.redirectErrorStream(true);
Process process = processBuilder.start();
Searching about this issue I saw that if I performed my .jar file as a service, I could not see the process started GUI because services executing in another desktop since Windows Vista. To create a service, I used Java Service Wrapper. On this tutorial, they teach how to use the wrapper.ntservice.interactive configuration to make for the service to display a GUI. They alert too:
"Starting with Windows Vista and Server 2008, Microsoft changed the way services are allowed to interact with the desktop. They decided that for security reasons, services are now only allowed to show their GUI on a special desktop that only the service can interact with. Unfortunately, this makes interactive features pretty much useless. We are looking into ways to display a GUI in a different way. Stay tuned.
If you do a search on the Internet with keywords of "Interactive services dialog Vista", you will find a number of references to the way Windows will display a dialog on the user desktop whenever a service has updated into GUI on the services desktop.
There are some important security reasons why this was disabled in Windows. But if you really need to reenable this functionality, it is possible to do so by editing the Windows Registry and setting HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows\NoInteractiveServices to 0. Always be very careful editing the registry as you can easily mess up your system by changing the wrong values."
I've been tried to configuration the NoInteractiveServices to 0, but yet do not work.
So, how can I execute a .jar program when windows initialize and the user do the login, and still be able to see the GUI of my opened process?

How to make the java application run as service that opens automatically at particular time

I am developing a windows based java application, One of the requirements for this application is, when this application is installed on other machines, it should open automatically at specified time and user has to select some option on the application, If the user didn't choose the options and close/minimize the application, the application should pop-up again after some time.
Please let me know how do I achieve the above functionality.
First of all, because of security reasons windows services are prevented from interaction with users via Gui - one should make significant efforts to show window from service process. You described process that unlikely may be called windows service, rather it should be scheduled. Some kind of Windows port of cron will help you. For instance, nnCron. It can in particular display, hide, close, kill, minimize, maximize and hide specified windows to system tray. Just in case, to fully answer your question - turning process (that has no GUI and was not created as service) into windows service is easy with help of srvany. Srvany.exe allows any Windows application to run as a service.

User is able to open the JavaFx desktop application more than once in a Windows machine

I am working on a JavaFX desktop application where the User is able to open the JavaFx desktop application more than once in a Windows machine. From Mac it cant be opened more than once.
The following code is used to launch the application:
Application.launch(ExampleApplication.class, (java.lang.String[])null);
Apart from JUnique library, is there any way to fix this issue ?
Any inputs will be helpful.
Application.launch() should only succeed once per a single application as per documentation. In addition it solely manages the current application and doesn't return until the application exits. If you want to be able to run the application more than once I'd recommend creating a standalone launcher for your application which runs a java process, which in turn runs your application. This way each time the launcher is executed a unique process is started and invokes the application.

Using Java Service Wrapper GUI to interact with desktop on windows

Help!!
Please I created a Java Windows Service using Java Service Wrapper, now my Service is supposed to pop up a dialog at certain times and this doesn't seem to work.
I've tested the service before installing and it worked just fine, but after installing the service nothing happens.
Please how do I solve this issue?
I think you need to use Java RMI, or something based on it: Jini, CORBA, remote OSGi, etc.
You should redesign your program according server-client architecture: windows service must be a client to gui app and call its methods to pop up proper widow in proper time. If you need callback from gui app to windows service you should also design the last as a client to the gui app.

how to provide update services to java application?

I am working on a java application, my requirement is to provide online product update services to application. What should I do?
Take a look at Java Web Start - the software gets updated automatically, and that's handled by the web start client. You just have to provide the update.
With Java Web Start, you launch applications simply by clicking on a Web page link. If the application is not present on your computer, Java Web Start automatically downloads all necessary files. It then caches the files on your computer so the application is always ready to be relaunched anytime you want—either from an icon on your desktop or from the browser link. And no matter which method you use to launch the application, the most current version of the application is always presented to you.

Categories

Resources