[ACCEPTED]-Java user.home is being set to %userprofile% and not being resolved-jvm

Accepted answer
Score: 25

The majority of the registry keys located 14 at:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

began 13 with %userprofile%. I updated all of the registry keys 12 that began with %userprofile% to begin with C:\Users\myusername. I verified 11 on Windows XP that the paths are in fact 10 hard coded and that %userprofile% is not used. The IT 9 guys mentioned that the registry keys defaulted 8 to use %userprofile% due to a default profile being used 7 within Windows 7. The JVM expects the Desktop 6 path to be hard coded. It will not evaluate 5 environment variables.

You can update the 4 registry keys one by one or you can export 3 the folder out and change the keys. Here 2 is how you can export and import the registry 1 keys:

  1. Go to Start > Run.
  2. Type regedit. This opens the registry editor.
  3. Browse to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders.
  4. Right click on Shell Folders and choose Export.
  5. Select the Desktop as the destination and enter Shell Folders for the file name and save the file.
  6. Open the file in a text editor and replace %userprofile% with C:\\Users\\yourusername. Save and close the file.
  7. Go back to the registry editor window and select File > Import from the main menu.
  8. Select Shell Folders.reg and click Open.
  9. Close the registry editor and delete the Shell Folders.reg file off of the desktop.
Score: 17

This is due to an long outstanding bug in 1 Java: http://bugs.sun.com/view_bug.do?bug_id=4787931

Score: 11

It looks to me as if - for whatever reasons 9 - %USERPROFILE% has not been set to a value. What do 8 you get if you type echo %USERPROFILE% on the command shell?

Maybe 7 it's not a OS feature but a configuration 6 issue. On my machine (Vista) %USERPROFILE% resolves to 5 my home directory and it's the same for 4 the Java property user.home


Here's an Vista/Windows7 3 issue with USERPROFILE and user.home: bug. May 2 not solve your problem might give you an 1 idea..

Score: 10

Until Java 8 where this is fixed, the solution 4 is to add this into the environment variables:

or 3 in command line:

I 2 saw the solution in the comments of this 1 page: http://www.timehat.com/javas-user-home-is-wrong-on-windows/

Score: 1

Single string values in registry have 2 8 types "REG_SZ" and "REG_EXPAND_SZ" and they treat "%data%" strings differently.

Type "REG_SZ" leaves any "%data%" as is.

Type 7 "REG_EXPAND_SZ" replaces "%data%" the "data" environment variable value 6 if defined otherwise no resolution takes 5 place.

The Windows GUI environment variable 4 editing applets selects the correct type 3 depending if "%name%" appears in the value field.

This 2 issue sounds like an installer making poor 1 choices when writing into the registry.

More Related questions