GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes run java .jar file on startup without user interfering Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "run java .jar file on startup without user interfering" Watch "run java .jar file on startup without user interfering" New topic
Author

run java .jar file on startup without user interfering

Devasia Manuel
Ranch Hand

Joined: May 13, 2008
Posts: 57
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

Joined: Dec 16, 2007
Posts: 151
May be I m still a beginner and I m not understanding the question, but what startup? What jar?


Cheers!
RSR
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39100
    
  23
Please do a search through the fora; a similar question comes up about once a month.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3606
    
  15
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 ?


Joanne
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

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.


SCJP, SCWCD.
|Asking Good Questions|
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39100
    
  23
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

Joined: May 13, 2008
Posts: 57
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

Joined: Aug 05, 2005
Posts: 3606
    
  15
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

Joined: Jun 06, 2007
Posts: 2716
    
    6

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

Joined: May 13, 2008
Posts: 57
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

Joined: Oct 13, 2005
Posts: 39100
    
  23
I think it means without the user having to take any action to start the application.
Devasia Manuel
Ranch Hand

Joined: May 13, 2008
Posts: 57
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

Joined: Jul 11, 2001
Posts: 15299
    
    6

Create a batch file that executes the java -jar myapp.jar command. Put this batch file in Window's Startup folder.


GenRocket - Experts at Building Test Data
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: May 13, 2008
Posts: 57
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

Joined: Oct 13, 2005
Posts: 39100
    
  23
Don't know.

But try:and save it as Foo.bat.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39100
    
  23
Good idea, Rob. I forgot about javaw.
Devasia Manuel
Ranch Hand

Joined: May 13, 2008
Posts: 57
I get it now, I think I'll just stick to .bat files.

Thanks for your help everybody!!!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39100
    
  23
You're welcome It's always nice to hear somebody has got their application to work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: run java .jar file on startup without user interfering