Application boot with Windows

Asked

Viewed 1,719 times

4

I have a Java desktop application, and I need it to be always started together with Windows (as a Windows service for example). This application should be running in the background and always be open, as it will perform tasks periodically using Quartz.

Would you like to know how I get it started and keep running at all times? If there is a fault and the application is not started, how to run a monitoring to try to run it again? The process should be automatic, because I will generate the installer of this application using Innosetup and customers will download the application and install.

Already warning that I did research, I saw about the Java Service Wrapper, but I do not know how to make it keep the application running and monitor tb. I would just like some guidance on.

  • you can create a task scheduled in the "Task Scheduler", see how it works create a basic task and understand its parameters, then you will need to create a *.Bath and/or *.vbs file to specify the parameters for it to be inserted automatically at the time of installation of your application on a client machine. Web search how to auto-backup using *.Bath and/or *.vbs files.

  • Have you solved your doubt? Did any of the answers help you?

2 answers

1

You can create a key in Regedit (Windows Registry) through Java itself using the following code :

 String valor = "\"javaw -jar " + System.getProperty("usuário.dir") + "\\meuJar.jar\"";
WinRegistry.writeStringValue(WinRegistry.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", "meu Jar aplicativo exe", value);

And if you want to remove later your key created to boot the application with Windows :

WinRegistry.deleteValue(WinRegistry.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", "meu Jar aplicativo exe");

Or you can also create a . bat file and put this code inside to create a key and make your application start along with Windows :

javaw -Xmx200m -jar C:\Caminho\para\jarfile\ArquivoJar.jar

And also if this hasn’t helped you yet, link.

0

You can create a service in Windows as follows, on the command line, running as administrator:

sc create meuServico binPath= "java -jar C:\to\my\service.jar" start= auto
                             ^^                                      ^
                       espaço||aspas                           espaço|

Preserve spaces and quotes added, as shown above.

The parameter start= auto indicates automatic start of the service when connecting the machine.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.