1

I added a key for the execution of a jar using the class that i found in an answer of Boann: read/write to Windows Registry using Java . I'm working in a virtual box virtualized windows 7.

If I add in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" a notepad.exe value, it starts at startup.

I wrote in this key the value, and the keyname JAVALL

javaw -Xmx200m -jar 

The entire code is:

if (Utilities.WindowsRegistry.isAvailable()) {+
            Utilities.WindowsRegistry.writeValue(
                    "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\", 
                    "JAVALL", 
                    "\"java.exe -jar "+ super.installPathFile + "\" ");
        }

Where super.installPathFile is similar at c:\users\kk\desktop\program.jar

But when I try to do the same in a jar in the desktop it doesn't start. I don't know where the error is!

Also another strange problem that I have when I go to the path in the regedit, the keynames and values are different that if I get its using the readValues() function. For example, I added the notepad in the key and it starts correctly, also i can see it in readValues() function. But when I go to the regedit I don't see the same keys that in the function! I'm working in a virtualized windows 7

Community
  • 1
  • 1
selan
  • 956
  • 3
  • 11
  • 27
  • 1
    what did you write in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\, please edit question... – Petter Friberg Dec 02 '15 at 15:47
  • Edited. What could be? – selan Dec 03 '15 at 14:40
  • Please show exactly what you have in the JAVALL key (use regEdit to view, copy and past..). I would try with full path to the java virtual machine es."c:\program files(x86)\java\jre1.8.31\bin\java.exe" -jar c:\users\kk\desktop\program.jar – Petter Friberg Dec 03 '15 at 14:57
  • That is another problem that I don't understand... When I go to the path in the regedit, the keynames and values are different that if I get it using the readValues() function. For example, I added the notepad in the key and it starts correctly, also i can see it in readValues() function. But when I go to the regedit I don't see the same keys that in the function! I'm working in a virtualized windows 7 – selan Dec 03 '15 at 15:08
  • For this I think you should open another question, with code you are using an example of what you get, an example of whats in regEdit.. ecc. For now what do you see in regEdit (windows) as a value of your JAVALL key – Petter Friberg Dec 03 '15 at 15:14
  • I can't found the JAVALL key in the regedit... – selan Dec 03 '15 at 15:18
  • Ok I if i write the whole path to java.exe it works! :D You want to write the answer? – selan Dec 03 '15 at 15:19
  • Yes, we need to close the question ; ), if it is working.... – Petter Friberg Dec 03 '15 at 15:35

1 Answers1

0

Converted comment into answer:

Include full path to java virtual machine es.

"c:\program files(x86)\java\jre1.8.31\bin\java.exe" -jar c:\users\kk\desktop\program.jar
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109