Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Add application to start up Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Add application to start up" Watch "Add application to start up" New topic
Author

Add application to start up

Mamu Jan
Ranch Hand

Joined: Sep 21, 2005
Posts: 45
Hi,

I'm developing an application in which I want to give my user an option to add my application to the windows start up. So, is there any API which can add a key (in this case my application) to the registry.

Thanx


There is no patch for ignorance...
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

The java.util.prefs.Preferences API.

For example see: http://forum.java.sun.com/thread.jspa?threadID=666927&messageID=3902531

The windows registry key you need to add is:

HKCU\Software\Microsoft\Windows\CurrentVersion\Run\<YourKeyAsAString>

with the value being the executable path.


My Blog: Down Home Country Coding with Scott Selikoff
Alan Moore
Ranch Hand

Joined: May 06, 2004
Posts: 262
The Preferences API can only read/write Registry keys under the keysTo access any other part of the Registry from within a Java program, you have to use JNI.
Mamu Jan
Ranch Hand

Joined: Sep 21, 2005
Posts: 45
Originally posted by Alan Moore:
The Preferences API can only read/write Registry keys under the keysTo access any other part of the Registry from within a Java program, you have to use JNI.


I've never used JNI before. Please can you guide me??!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

You don't have to program the whole thing yourself - have a look on for example http://sourceforge.net and do a search for a Java library to access the Windows registry.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Stuart Ash
Ranch Hand

Joined: Oct 07, 2005
Posts: 637
I don't think you need any registry write at all, just copy the shortcut to the appropriate startup folder, say C:\Documents and Settings\All Users\Start Menu\Programs\Startup. And you should be able to get it. Let us know if it worked.



ASCII silly question, Get a silly ANSI.
Mamu Jan
Ranch Hand

Joined: Sep 21, 2005
Posts: 45
Ok thanx guys ! Problem solved. Found dis code snippet in da Sun Developer forum.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Add application to start up
 
Similar Threads
log4j -- NoClassDefFoundError: org/apache/log4j/Category
Enity bean deployment on weblogic server 7.1
Struts Plugin - Getting webapplicationcontext or service factory in struts plug-in class
Design Questions
struts2 configuration provider