package com.hbbh.adapter.utils;
|
|
|
import java.util.Properties;
|
|
/**
|
* 环境变量工具
|
* for fameview
|
*/
|
public class PathUtil {
|
|
|
private static final String key= "java.library.path";
|
private static final String path="user.dir";
|
//Windows
|
private static final String regex_win= ";";
|
// mac
|
private static final String regex_mac= ":";
|
|
private static final String _mac= "mac";
|
private static final String _windows= "windows";
|
|
private static final String os_name= "os.name";
|
|
|
/**
|
* 输出
|
* 1.当前程序必须在Windows环境运行
|
* 2.第三方依赖包存放位置
|
* 3.环境变量所在位置
|
*/
|
public static void printLibrary(){
|
String regex=null;
|
String osName = System.getProperty(os_name).toLowerCase();
|
if (osName.contains(_mac)){
|
System.out.println("警告:当前程序必须在Windows环境下执行");
|
regex=regex_mac;
|
}else if (osName.contains(_windows)){
|
regex=regex_win;
|
}else if (null==osName){
|
System.out.println("警告:当前程序必须在Windows环境下执行");
|
regex=regex_win;
|
}
|
|
System.out.println("当前运行操作系统:"+osName);
|
System.out.println("-------------- 引入第三方包环境变量 -------------- ");
|
String property = System.getProperty(key);
|
if (property.contains(regex)) {
|
String[] split = property.split(regex);
|
for (String s : split) {
|
System.out.println("需要在文件--> "+s+" | 下放置依赖包");
|
}
|
} else {
|
System.out.println("需要在文件--> "+property+" | 下放置依赖包");
|
}
|
System.out.println("-------------- 或者重新制定环境变量 ------------------- ");
|
}
|
|
public static void main(String[] args) {
|
//printLibrary();
|
Properties properties = System.getProperties();
|
}
|
|
|
}
|