Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

run java .jar file on startup without user interfering

 
Devasia Manuel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to know how I could run a jar file every time I startup without any user interfering (such as placing the jar file in the startup folder).
 
rakesh sugirtharaj
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be I m still a beginner and I m not understanding the question, but what startup? What jar?
 
Campbell Ritchie
Sheriff
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do a search through the fora; a similar question comes up about once a month.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Devasia Manuel:
I would like to know how I could run a jar file every time I startup without any user interfering (such as placing the jar file in the startup folder).


By startup, do you mean when the machine first starts up or when you actually log in ? Also what operating system are you using ?
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Campbell Ritchie:
Please do a search through the fora; a similar question comes up about once a month.


Something like this one.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks an excellent thread, Amit, thank you. Typical JavaRanch stuff. Two useful posts then it disintegrates into banter between the staff
 
Devasia Manuel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the Windows XP OS, and when I mean startup, I mean every time the computer boots. For example, if I shut down the computer then reboot it, he jar file should run.

I know how to do this quite easily by putting the jar file in the startup directory but I would like more advanced means of doing it.
[ November 07, 2008: Message edited by: Devasia Manuel ]
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set your jar file up to run as a Windows Service. There are several programs that will do this for you. Search for Windows Services Wrapper
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Campbell Ritchie:
That looks an excellent thread, Amit, thank you. Typical JavaRanch stuff. Two useful posts then it disintegrates into banter between the staff


 
Devasia Manuel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't all the methods listed above mean the user interfering...I am thinking more on the lines on letting java create a registry entry that would make the program run on startup. Is that possible with java?
 
Campbell Ritchie
Sheriff
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it means without the user having to take any action to start the application.
 
Devasia Manuel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I meant without the user having to do anything to start the application and make it run on startup
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a batch file that executes the java -jar myapp.jar command. Put this batch file in Window's Startup folder.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Devasia Manuel:
I meant without the user having to do anything to start the application and make it run on startup
What Joanne Neal said. Make the application into a service and configure it to run automatically.

Yes, this probably requires some registry entries or something like that. But you don't need to use Java to set up the service.
 
Devasia Manuel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the batch file method looks more appealing to me...How exactly do I make a batch file that will allow me to run the program
 
Campbell Ritchie
Sheriff
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know.

But try:and save it as Foo.bat.
 
Rob Spoor
Sheriff
Pie
Posts: 20533
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's a windowed application, creating a Windows shortcut may be a bit better. It's basically the same as the BAT file contents but replace java.exe with javaw.exe. This way no DOS box will be shown.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good idea, Rob. I forgot about javaw.
 
Devasia Manuel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get it now, I think I'll just stick to .bat files.

Thanks for your help everybody!!!
 
Campbell Ritchie
Sheriff
Pie
Posts: 48981
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome It's always nice to hear somebody has got their application to work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic