问题描述
我们公司最近从 Windows XP 升级到了 Windows 7 Enterprise.JDK 安装不再将 user.home 设置为用户目录的完整路径,而是将 user.home 设置为 %userprofile%
.这会导致 Eclipse、Maven 等应用程序出现很多问题.我现在必须在 JVM 中为每个应用程序设置 -Duser.home.有没有其他人经历过这个?有解决办法吗?这是否与安装 Windows 7 企业版有关?我试过 1.5 JDK 和 1.6 JDK.
Our company recently upgraded from Windows XP to Windows 7 Enterprise. The JDK installation is no longer setting user.home to the full path of the user directory, but instead is setting user.home to %userprofile%
. This is causing a lot of issues with applications such as Eclipse, Maven, etc. I now have to set -Duser.home in the JVM for each application. Has anyone else experienced this? Is there a fix for this? Would this be related to the installation of Windows 7 Enterprise? I have tried the 1.5 JDK and the 1.6 JDK.
这里是属性列表.注意 user.home:
Here is the list of properties. Note user.home:
-- listing properties --
java.runtime.name=Java(TM) SE Runtime Environment
sun.boot.library.path=C:Program FilesJavajre6in
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:UserspolitespDesktop
java.runtime.version=1.6.0_18-b07
java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs=C:Program FilesJavajre6libendorsed
os.arch=x86
java.io.tmpdir=C:UserspolitespAppDataLocalTemp
line.separator=
java.vm.specification.vendor=Sun Microsystems Inc.
user.variant=
os.name=Windows 7
sun.jnu.encoding=Cp1252
java.library.path=C:WINDOWSsystem32;.;C:WINDOWSSun...
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 FilesJavajre6
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 FilesJavajre6libext;C:...
sun.boot.class.path=C:Program FilesJavajre6lib
esour...
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 的错误链接:
Using the link to the bug from Andreas_D I discovered:
在我安装的 Windows 7 Enterprise 中,HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerShell FoldersDesktop
的值是 %userprofile%Desktop.
The value of HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerShell FoldersDesktop
is %userprofile%Desktop on my installation of Windows 7 Enterprise.
当我将此键的值更改为 C:UserspolitespDesktop
时,我的 user.home 会正确解析.知道为什么会这样吗?
When I change the value of this key to C:UserspolitespDesktop
, my user.home resolves correctly. Any idea why this is happening?
推荐答案
大部分注册表项位于:
HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerShell文件夹
HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerShell Folders
从 %userprofile%
开始.我将所有以 %userprofile%
开头的注册表项更新为以 C:Usersmyusername
开头.我在 Windows XP 上验证了路径实际上是硬编码的,并且没有使用 %userprofile%
.IT 人员提到,由于 Windows 7 中使用了默认配置文件,因此注册表项默认使用 %userprofile%
.JVM 期望桌面路径是硬编码的.它不会评估环境变量.
began with %userprofile%
. I updated all of the registry keys that began with %userprofile%
to begin with C:Usersmyusername
. I verified on Windows XP that the paths are in fact hard coded and that %userprofile%
is not used. The IT guys mentioned that the registry keys defaulted to use %userprofile%
due to a default profile being used within Windows 7. The JVM expects the Desktop path to be hard coded. It will not evaluate environment variables.
您可以一一更新注册表项,也可以将文件夹导出并更改密钥.以下是导出和导入注册表项的方法:
You can update the registry keys one by one or you can export the folder out and change the keys. Here is how you can export and import the registry keys:
- 转到开始 > 运行.
- 键入
regedit
.这将打开注册表编辑器. - 浏览到
HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerShell 文件夹
. - 右击
Shell Folders
并选择Export. - 选择桌面作为目标,输入
Shell Folders
作为文件名并保存文件. - 在文本编辑器中打开文件并将
%userprofile%
替换为C:\Users\yourusername
.保存并关闭文件. - 返回注册表编辑器窗口并从主菜单中选择文件">导入".
- 选择
Shell Folders.reg
并点击打开. - 关闭注册表编辑器并从桌面删除
Shell Folders.reg
文件.
- Go to Start > Run.
- Type
regedit
. This opens the registry editor. - Browse to
HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerShell Folders
. - Right click on
Shell Folders
and choose Export. - Select the Desktop as the destination and enter
Shell Folders
for the file name and save the file. - Open the file in a text editor and replace
%userprofile%
withC:\Users\yourusername
. Save and close the file. - Go back to the registry editor window and select File > Import from the main menu.
- Select
Shell Folders.reg
and click Open. - Close the registry editor and delete the
Shell Folders.reg
file off of the desktop.
这篇关于Java user.home 被设置为 %userprofile% 并且没有被解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!