Java认为我的主文件夹是C盘?

编程入门 行业动态 更新时间:2024-10-21 17:32:26
本文介绍了Java认为我的主文件夹是C盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

出于某种原因,我必须更改某些配置或其他内容,因为在一个全新的项目中,我输入了这个:

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盘?

本文发布于:2023-11-28 16:50:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643196.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:主文   Java   件夹是

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!