社区
非技术区
帖子详情
[请问]:用什么方法判断当前os是Windows还是Linux?
aistill
2002-03-14 10:08:04
我的系统有一个properties文件,里面保存连接池名称,JDBC Class名等信息,在Windows下是放在c:\,然后在程序中读C:\下文件,但移植到Linux下需要修改源代码,所以想用一个方法判断当前os后再读取不同路径来实现平台无关!
或者:
在bean中如何得到web服务器根路径的物理路径呢?(指http://localhost/的物理路径)
...全文
312
14
打赏
收藏
微信扫一扫
点击复制链接
分享
下载分享明细
分享
举报
写回复
14 条
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
aistill
2002-03-16
得到os.name Windows,再加上os.Version就可以判断了!
打赏
举报
回复
赞
aistill
2002-03-16
路径问题早已经搞定,其实用"/"就可以了
/:就是表示你程序所在分区的根目录
例如:假如你的project在e:
/dirname/subdir:就是表示e:\dirname\subdir目录
这个做得很不错!!
打赏
举报
回复
赞
ChDw
2002-03-16
其实我觉得你应该用ResourceBundle而不要使用C:\这样存放
打赏
举报
回复
赞
dope
2002-03-14
不是还有os.version吗
打赏
举报
回复
赞
snowredfox
2002-03-14
我是win2000, sp.getProperty("os.name")咋输出window NT呢?
打赏
举报
回复
赞
0legend
2002-03-14
sorry forget ""
Properties sp = System.getProperties();
sp.getProperty("os.name");
打赏
举报
回复
赞
aistill
2002-03-14
刚刚看了去年5月份的帖子,已经有答案了,用System.getProperties(os.name)得到os名称,
其他内容可以用如下方法列出:
(System.getProperties()).list(System.out);
有兴趣的朋友可以看看
http://www.csdn.net/expert/topic/131/131399.xml?temp=.7794153
打赏
举报
回复
赞
GJA106
2002-03-14
学习!
打赏
举报
回复
赞
0legend
2002-03-14
Properties sp = System.getProperties();
sp.getProperty(os.name);
打赏
举报
回复
赞
GJA106
2002-03-14
不知道java API有没有这个功能。
不过可以用JNI来实现。
用C++来判断当前os是Windows还是Linux,用JNI在java中调用结果值。
打赏
举报
回复
赞
dope
2002-03-14
System.getProperties()
打赏
举报
回复
赞
aistill
2002-03-14
请大家帮帮忙!
打赏
举报
回复
赞
0legend
2002-03-14
win 2000的“系统变量” 就是windows NT吧,你可以查一下“我的电脑”“属性”
打赏
举报
回复
赞
snowredfox
2002-03-14
如果我想得到windows 2000呢?
打赏
举报
回复
赞
相关推荐
java如何
判断
当前
系统
是
windows
还
是
linux
?
java如何
判断
当前
系统
是
windows
还
是
linux
?
判断
当前
系统
是
Linux
还
是
Windows
... /** * @author tqf * @Description
判断
当前
系统类型
Linux
还
是
Windows
* @Version 1.0 * @since 2022-04-12 11
:
34 */ public class
Os
PathUtil { public static String convertToUnix(St.
php
判断
操作系统为
linux
,php如何
判断
当前
的操作系统
是
linux
还
是
windows
php自身有许多与运行操作系统有关的系统预定义变量,通过这些预定义变量可以很轻松的
判断
当前
的系统
是
windows
还
是
Linux
还
是
unix。下面就一一列出这些比较实
用
的预定义变量并稍作分析。php_uname()...
python
用
linux
还
是
windows
_【已解决】Python中
判断
当前
系统
是
Windows
还
是
Linux
(Ubuntu等)
还
是
Mac,以及获得对应的系统版本信息...
结果却在Ubuntu中出现错误了: AttributeError
:
‘module’ object has no attribute ‘get
windows
version’ 现在希望,从Python中,能够
判断
当前
系统
是
Windows
还
是
Linux
还
是
Mac,以及获得对应的系统的版本信息。...
golang:
判断
当前
系统
是
Linux
还
是
Windows
package main import ( "runtime" "fmt" ) func main() { sysType
:
= runtime.GO
OS
if sysType == '
linux
' { //
LINUX
系统 } if sysType == '
windows
' { //
windows
系统 } }
发帖
非技术区
微信扫一扫
点击复制链接
分享社区
下载分享明细
2.3w+
社区成员
7.0w+
社区内容
Java 非技术区
社区管理员
加入社区
帖子事件
创建了帖子
2002-03-14 10:08
社区公告
暂无公告