通过 Java servlet 检测操作系统或计算机名称
我有一个在 Windows 计算机上开发的 Java Web 应用程序,并将部署在 Unix 计算机上。
两者的一些文件路径设置和权限详细信息有所不同(我无法更改此设置)。有没有某种方法可以通过检测操作系统或计算机名称来检测应用程序所在的机器(这只是两种机器之一),以便我可以使用适当的设置。
I have a Java web app that I develop on a Windows machine and will deploy on a Unix machine.
There are some file path settings and permissions details that differ on the two (and there is nothing I can do to change this). Is there some way of detecting which machine the app is sitting on (it's only one of two), either by detecting the operating system or the computer's name so I can then using the appropriate settings.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
计算机名称和操作系统名称是两个不同的属性,用于获取计算机名称使用
和获取操作系统名称使用
Abdul Khaliq
Computer name and OS name are two different properties to get computer name use
and to get os name use
Abdul Khaliq
您可以用来
了解操作系统名称。
请访问 https://docs 获取更多信息。 oracle.com/javase/1.5.0/docs/api/java/lang/System.html。
You can use
to know the operating system name.
Get more info at https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/System.html.
检查这个: http://www.roseindia.net/java/beginners/OSInformation.shtml
Check this: http://www.roseindia.net/java/beginners/OSInformation.shtml
您可以使用 System.getProperty("os.name")
You can use
System.getProperty("os.name")