2

Possible Duplicate:
Auto startup for java desktop application?

I have a Java desktop application using netbeans 6.5.1. I was wondering if anybody can help me in suggesting code for autosatrting the Jar file on windows start up.

Thanks in advance Bhavi

Community
  • 1
  • 1
Bhavi
  • 61
  • 1
  • 2
  • 4
  • Check this question : http://stackoverflow.com/questions/979451/auto-startup-for-java-desktop-application – Shoban Jun 22 '09 at 07:02

2 Answers2

3

It depends on what you mean by "Windows Startup". Running it in the background without a user logging in, you'd have to create a Windows Service wrapper.

In case "Windows Startup" means "run when the user logs in", create a batch file that starts your application and put a link to that batch file into the user's Autostart folder (or the "All Users" Autostart folder).

EDIT To clarify what I mean according to your comments.

You said you were a .NET programmer, so we can just talk like you'd develop a .NET application:

  1. If your program should behave like a Windows Service, you'd need some kind of service wrapper that acts as the "real" Windows service and starts your program when it is started using the Service Manager (you can not develop a Windows Service in Java so far, so you need this wrapper).

  2. If your program should behave like a normal application and just be started whenever a user logs on (example: Skype or WinAmp Agent), you'll just have to start your program putting a link to it into the user's AutoStart folder.

In case of 1), you'd have to follow the answers of the other posters - I've never done that myself before, but I'm sure it can be done. (Maybe this link will help you: http://edn.embarcadero.com/article/32068)

In case of 1), just create a batch file that runs your application and create a link to that batch file in the user's/All Users' AutoRun folder.

Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
  • Thankx Thorsten, But i am unable to get you. Basically i am a .net programmer and a newbie in Java, I was just wondering if any code is available to make our java application starting at any OS startup – Bhavi Jun 22 '09 at 07:25
  • rather Autostarting a jar file at OS startup – Bhavi Jun 22 '09 at 07:26
  • Well, let's think in .NET terms then: Do you wish to create something like a Windows Service that runs in background when Windows starts up or do you want an Autorun application that is automatically started when a user logs in? I'll clarify both by editing my post. – Thorsten Dittmar Jun 22 '09 at 07:31
  • Thanks Thorsten, I have got rid of the problem. Issue is fixed now. Cheers – Bhavi Jun 22 '09 at 12:53
  • Well, if my reply helped solve your problem, I'd appreciate it if you marked it as accepted answer. – Thorsten Dittmar Jun 22 '09 at 12:56
  • @Bhavi can u tell me how you accomplished this task..i want to start my java app when user login into the system.. – Laxman Rana Apr 16 '12 at 05:15
1

We use Windows-Tomcat's tomcat6w.exe (renamed to OurApplication.exe) to create a service for our Java application. Then we just set it to autostart.

akarnokd
  • 69,132
  • 14
  • 157
  • 192