zoukankan      html  css  js  c++  java
  • 通过System获取java环境变量的路径

    通过System获取java环境变量的路径代码为:

    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Map;
    import java.util.Properties;
    
    public class Sys {
    
    	public static void main(String[] args) throws Exception {
    		//获取素所有的环境变量
    Map<String,String> env = 	System.getenv();
    for (String name : env.keySet()) {
    	System.out.println(env.get(name));
    }
    		
    
    //获取指定环境变量的值
    System.out.println(System.getenv("JAVA_HOME"));
    
    
    //获取所有系统属性
    Properties  props = System.getProperties();
    
    //将所有的系统文件保存
    
    props.store(new FileOutputStream("C:\Users\Administrator\Desktop\配置.txt"),"System Properties");
    
    //输出特定的系统属性
    System.out.println(System.getProperty("os.name"));
    
    	}
    }
    

      输出结果为:

    C:UsersAdministratorAppDataLocal
    6
    NO
    MS-20160512ARFF
    \MS-20160512ARFF
    C:jdk64jdk
    Console
    C:ProgramData
    x86
    C:Windowssystem32WindowsPowerShellv1.0Modules
    C:
    Destination=file
    C:UsersAdministratorAppDataRoaming
    Administrator
    C:BVTBinTestsinstallpackagecsilogfile.log
    C:Program Files (x86)
    C:Program Files (x86)Common Files
    C:/Program Files (x86)/Java/jre1.8.0_144/bin/client;C:/Program Files (x86)/Java/jre1.8.0_144/bin;C:/Program Files (x86)/Java/jre1.8.0_144/lib/i386;C:ProgramDataOracleJavajavapath;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:jdk64jdkin;C:jdk64jdkjrein;D:JavaIdein;C:Program Files (x86)CanonEasy-WebPrint EXin;D:JavaIdemysqlinC:jdk64jdkin;C:jdk64jdkjrein;;C:UsersAdministratoreclipsejava-oxygeneclipse;
    .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    Windows_NT
    AMD64
    3
    MS-20160512ARFF
    1
    3a09
    .;C:jdk64jdklib;C:jdk64jdklib	ools.jar
    C:Program FilesCommon Files
    C:Windowssystem32cmd.exe
    C:ProgramData
    C:Program Files
    UsersAdministrator
    C:Windows
    C:UsersADMINI~1AppDataLocalTemp
    C:
    Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
    C:UsersAdministrator
    C:UsersADMINI~1AppDataLocalTemp
    C:Program Files (x86)Common Files
    C:Program Files (x86)
    C:UsersPublic
    4
    C:Windows
    C:jdk64jdk
    Windows 7
    

      

  • 相关阅读:
    br-lan、eth0、eth1及lo (转)
    openwrt MT7628 编译前更改为DHCP,root 密码、ssid、时区、主机名
    Openwrt Uboot烧写
    区块链公链“三元悖论”专题之可扩展性(Scalability)
    物联网开发|如何选择一款适合你的物联网操作系统?
    oracle 处理Session不够用
    Redis 数据总结 (2.命令实现逻辑)
    Redis 数据总结(1 数据导入)
    Redis 数据库使用和搭建
    MySql 存储大量长字节 Text报错处理办法
  • 原文地址:https://www.cnblogs.com/charlypage/p/8908133.html
Copyright © 2011-2022 走看看