web-dev-qa-db-ja.com

Java user.homeは%userprofile%に設定されており、解決されていません

当社は最近Windows XPからWindows 7 Enterpriseにアップグレードしました。JDKインストールはuser.homeに設定されなくなりましたユーザーディレクトリのフルパスですが、代わりにuser.homeを%userprofile%に設定しています。これにより、Eclipse、Mavenなどのアプリケーションで多くの問題が発生します。各アプリケーションのJVM。他の誰かがこれを経験しましたか?これに対する修正はありますか?これはWindows 7 Enterpriseのインストールに関連しますか?1.5 JDKおよび1.6 JDKを試しました。

プロパティのリストは次のとおりです。 user.homeに注意してください。

-- listing properties --
Java.runtime.name=Java(TM) SE Runtime Environment
Sun.boot.library.path=C:\Program Files\Java\jre6\bin
Java.vm.version=16.0-b13
Java.vm.vendor=Sun Microsystems Inc.
Java.vendor.url=http://Java.Sun.com/
path.separator=;
Java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=Sun.io
user.country=US
Sun.Java.launcher=Sun_STANDARD
Sun.os.patch.level=
Java.vm.specification.name=Java Virtual Machine Specification
user.dir=C:\Users\politesp\Desktop
Java.runtime.version=1.6.0_18-b07
Java.awt.graphicsenv=Sun.awt.Win32GraphicsEnvironment
Java.endorsed.dirs=C:\Program Files\Java\jre6\lib\endorsed
os.Arch=x86
Java.io.tmpdir=C:\Users\politesp\AppData\Local\Temp\
line.separator=

Java.vm.specification.vendor=Sun Microsystems Inc.
user.variant=
os.name=Windows 7
Sun.jnu.encoding=Cp1252
Java.library.path=C:\WINDOWS\system32;.;C:\WINDOWS\Sun\...
Java.specification.name=Java Platform API Specification
Java.class.version=50.0
Sun.management.compiler=HotSpot Client Compiler
os.version=6.1
user.home=%userprofile%
user.timezone=
Java.awt.printerjob=Sun.awt.windows.WPrinterJob
file.encoding=Cp1252
Java.specification.version=1.6
user.name=politesp
Java.class.path=.
Java.vm.specification.version=1.0
Sun.Arch.data.model=32
Java.home=C:\Program Files\Java\jre6
Java.specification.vendor=Sun Microsystems Inc.
user.language=en
awt.toolkit=Sun.awt.windows.WToolkit
Java.vm.info=mixed mode, sharing
Java.version=1.6.0_18
Java.ext.dirs=C:\Program Files\Java\jre6\lib\ext;C:...
Sun.boot.class.path=C:\Program Files\Java\jre6\lib\resour...
Java.vendor=Sun Microsystems Inc.
file.separator=\
Java.vendor.url.bug=http://Java.Sun.com/cgi-bin/bugreport...
Sun.cpu.endian=little
Sun.io.unicode.encoding=UnicodeLittle
Sun.desktop=windows
Sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+m...

更新:

Andreas_Dからのバグへのリンクを使用して、私が発見した:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktopの値は、Windows 7 Enterpriseのインストールでは%userprofile%\ Desktopです。

このキーの値をC:\Users\politesp\Desktopに変更すると、user.homeは正しく解決されます。なぜこれが起こっているのでしょうか?

34
Dan Polites

レジストリキーの大部分は次の場所にあります。

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

%userprofile%で始まりました。 %userprofile%で始まるすべてのレジストリキーをC:\ Users\myusernameで始まるように更新しました。 WindowsでXPパスが実際にハードコーディングされており、%userprofile%が使用されていないことを確認しました。IT担当者は、デフォルトのプロファイルによりJVMは、デスクトップパスがハードコードされていることを想定しており、環境変数を評価しません。

レジストリキーを1つずつ更新するか、フォルダーをエクスポートしてキーを変更できます。レジストリキーをエクスポートおよびインポートする方法は次のとおりです。

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.
24
Dan Polites

これは、Javaの長い未解決のバグによるものです。 http://bugs.Sun.com/view_bug.do?bug_id=4787931

15
Brett

-何らかの理由で%USERPROFILE%が値に設定されていないように見えます。コマンドシェルでecho %USERPROFILE%と入力すると何が得られますか?

多分それはOSの機能ではなく、設定の問題です。私のマシン(Vista)%USERPROFILE%は私のホームディレクトリに解決され、Javaプロパティuser.home

編集

USERPROFILEとuser.homeのVista/Windows7の問題は次のとおりです。 bug 。問題を解決できない場合があります。

11
Andreas_D

Java 8これが修正されるまで、解決策は環境変数にこれを追加することです:
_ Java_OPTIONS:-Duser.home =%HOMEDRIVE %% HOMEPATH%

またはコマンドラインで:
set _Java_OPTIONS = -Duser.home =%HOMEDRIVE %% HOMEPATH%

このページのコメントで解決策を見ました: http://www.timehat.com/javas-user-home-is-wrong-on-windows/

10
Luka Bradeško

レジストリ内の単一の文字列値には、2つのタイプ"REG_SZ"および"REG_EXPAND_SZ"があり、"%data%"文字列の扱いが異なります。

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

タイプ"REG_EXPAND_SZ"は、"%data%"を置き換えます"data"環境変数の値が定義されている場合は、それ以外の場合、解決は行われません。

Windows GUI環境変数編集アプレットは、値フィールドに"%name%"が表示されるかどうかに応じて正しいタイプを選択します。

この問題は、インストーラーがレジストリに書き込む際に適切な選択を行わないように聞こえます。

1
Conrad T. Pino