views:

41

answers:

2

Hi,

I added a value at:

HKLM\Software\Microsoft\Windows\CurrentVersion\Run

That looks like this:

Value Name: LDE
Value Data: "java -jar C:\LDE\lde.jar"

Really with the quotes (Because all the others where also with quotes). After adding this, I restarted my computer, but it didn't start automatically.

Will wrapping my jar in an exe help?

I'm running Windows 7.

Any help?
Thanks in advance.


Update:

When I remove the quotes, it works. But now there is appears also a terminal, which I don't need...

A: 

This is very simple. You will find the startup folder in the C:/Documents and Settings/AllUsers/YourUserName/StartUp. It will be on similar kind of path just check it. Then just paste your jar file in that folder and it will work nice. Remember that you put the jar file in the startup folder of your user name folder. You may find that this folders might be hidden so just check it out. If you find this answer useful vote it. Enjoy.....

Darshan G. Prajapati
On sites like this, everyone knows we have to vote useful information. So don't say it, if you keep doing it, I think people are going to vote you down...
Martijn Courteaux
+3  A: 

A couple of things to note here, concerning the two different issues in the problem:

Format of Windows Run keys

From the Microsoft Windows XP knowledge base:

Run keys cause programs to automatically run each time that a user logs on. The Windows XP registry includes the following four Run keys:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

Each of these keys has a series of values. The values allow multiple entries to exist without overwriting one another. The data value for a value is a command line.

Note the emphasis on the last line. The moment quotes are used, the command is bound to fail execution in the same manner it fails as if executed from a command prompt.

Also, note that the above approach is for Windows XP and does hold good for Windows 7. More details can be found in this Microsoft Technet article on the options available in Windows 7.

The javaw vs java application launcher

Once the java process can be initialized at Windows startup, one will get a console window that continues to stay around until the process is terminated. This occurs if the java executable is utilized to initialize the application.

From the technotes of the java application launcher:

The javaw command is identical to java, except that with javaw there is no associated console window. Use javaw when you don't want a command prompt window to appear. The javaw launcher will, however, display a dialog box with error information if a launch fails for some reason.

Therefore, if you wish to avoid opening a console window for the Java process, you ought to use the javaw executable.

Vineet Reynolds