Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to automatically lunch my app when windows boots?

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what efforts i can make so that my java application automatically starts when windows(OS) start or boots ?
but solutions should be 100% programmatically , can any one has any idea about this ?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote:what efforts i can make so that my java application automatically starts when windows(OS) start or boots ?


Sounds like you want it to be a Service. Google for java windows service, or look into Tanuki Service Wrapper.

but solutions should be 100% programmatically


If you mean what I think you mean by that, then it's not possible.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:

but solutions should be 100% programmatically


If you mean what I think you mean by that, then it's not possible.


He could go and get a job for microsoft, and make everyone's computer start it at runtime
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wendy Gibbons wrote:
Jeff Verdegan wrote:

but solutions should be 100% programmatically


If you mean what I think you mean by that, then it's not possible.


He could go and get a job for microsoft, and make everyone's computer start it at runtime


You'd think by now I'd know better than to use absolutes around a bunch of programmers.
 
Tim Moores
Bartender
Posts: 2855
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternatively, you can put a .bat file that starts the app in the AutoStart folder.
 
Stephan van Hulst
Bartender
Pie
Posts: 5912
66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or just put a symbolic link there.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:Alternatively, you can put a .bat file that starts the app in the AutoStart folder.

yes that could be one solution but that require human intervention, i m finding solution programmatically
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote:
Tim Moores wrote:Alternatively, you can put a .bat file that starts the app in the AutoStart folder.

yes that could be one solution but that require human intervention, i m finding solution programmatically


Define exactly what you mean by "programmatically." A .bat file is a programmatic approach, in my opinion.

If you mean what I think you mean--simply by what you put in your Java code--then it is not possible.
 
Philip Thamaravelil
Ranch Hand
Posts: 99
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:
naved momin wrote:
Tim Moores wrote:Alternatively, you can put a .bat file that starts the app in the AutoStart folder.

yes that could be one solution but that require human intervention, i m finding solution programmatically


Define exactly what you mean by "programmatically." A .bat file is a programmatic approach, in my opinion.

If you mean what I think you mean--simply by what you put in your Java code--then it is not possible.




Hypothetically, you could have your Java program create the batch file in the startup directory. So only an initial run of the program would be required. Just my two cents.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Philip Thamaravelil wrote:
Jeff Verdegan wrote:
naved momin wrote:
Tim Moores wrote:Alternatively, you can put a .bat file that starts the app in the AutoStart folder.

yes that could be one solution but that require human intervention, i m finding solution programmatically


Define exactly what you mean by "programmatically." A .bat file is a programmatic approach, in my opinion.

If you mean what I think you mean--simply by what you put in your Java code--then it is not possible.




Hypothetically, you could have your Java program create the batch file in the startup directory. So only an initial run of the program would be required. Just my two cents.


but would that be an installer step
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say you should make your app a service, as Jeff suggested. You could then use for example MakeMSI to create Windows Installer file (.msi) and have the service registered by it.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can use Java Service Wrapper(32bit) or YAJSW(64bit). Old thread
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Philip Thamaravelil wrote:
Jeff Verdegan wrote:
naved momin wrote:
Tim Moores wrote:Alternatively, you can put a .bat file that starts the app in the AutoStart folder.

yes that could be one solution but that require human intervention, i m finding solution programmatically


Define exactly what you mean by "programmatically." A .bat file is a programmatic approach, in my opinion.

If you mean what I think you mean--simply by what you put in your Java code--then it is not possible.




Hypothetically, you could have your Java program create the batch file in the startup directory. So only an initial run of the program would be required. Just my two cents.

thats nice one ....good job...
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote:
Philip Thamaravelil wrote:Hypothetically, you could have your Java program create the batch file in the startup directory. So only an initial run of the program would be required. Just my two cents.

thats nice one ....good job...

A shortcut (.lnk) pointing to javaw.exe with proper arguments might be better, you probably don't want to display the console to the user. Making it would be a bit harder, though. In either case, you need to obtain the right location of the startup folder from Windows. Its location is not present (as of Windows 7) in environment variables and the name depends (among other things) on the version and language of the system. For both of these task you'll probably have to call Windows system functions, should be doable with JNA.

However, you stated you wanted your program to run when Windows boot. This solution would run it when a user logs in. These are different things.

I've already mentioned MakeMSI. I was able to produce my first msi file in about two days, though I didn't know virtually anything about Windows Installer beforehand. MSI would easily allow you to create the shortcut in startup folder during the installation, without having to bother about the exact location of that folder. Also, chances are that a MSI package will function better on newer Windows versions, where User Account Control is in place.

If you go the other way, make sure to provide ways to cleanly uninstall your program again. You don't want to alienate your users.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic