出于某种原因,我必须更改某些配置或其他内容,因为在一个全新的项目中,我输入了这个:
For some reason, I must have changed some configuration or something, because, in a brand new project, I am entering this:
System.out.println(System.getProperty(user.home));
并获得以下输出:
C:\
以前它曾用过返回类似 C:\ Users \ ...
Whereas before, it used to return something like C:\Users\...
是否需要清除配置文件?
Is there a configuration file I need to clear?
推荐答案当你调用 System.getProperty(user.home); 在您的代码中,JVM不使用Windows环境变量来确定用户配置文件的位置,而是访问引用用户桌面目录的注册表项。然后它获取桌面的父目录并假定它是用户的配置文件目录。因此,请在 HKEY_CURRENT_USER \Software \ Microoft \ Windows \ CurrentVersion \Explorer \ Shell文件夹\ &中查看桌面目录的注册表项。相应地更新它。如果Desktop目录的registery密钥值为 C:\\ ,则JVM返回值 C:\ 当您在代码中调用 System.getProperty(user.home); 时。例如,如果您可以将注册表中的桌面密钥输入修改为 C:\ Users \YourName \Desktop ,您将获得 C:\ Users \YourName 在您的代码中调用 System.getProperty(user.home); 时。
When you invokes the "System.getProperty("user.home");" in your code, the JVM does not use the Windows environment variable to determine the location of the user’s profile, but instead access the registry key that references the user’s desktop directory. It then takes the parent directory of the desktop and assumes that is the user’s profile directory. So please check the registry entry of your Desktop directory in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\ & update it accordingly. If the value of registery key for your Desktop directory is "C:\\", the JVM returns the value "C:\" while you invokes "System.getProperty("user.home");" in your code. For example if you could modify the Desktop key entery in the registery to "C:\Users\YourName\Desktop", you will get "C:\Users\YourName" while invoking the "System.getProperty("user.home");" in your code.
谢谢!
更多推荐
Java认为我的主文件夹是C盘?
发布评论