• 通过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
    

      

  • 相关阅读:
    李宏毅back propagation(lecturte7 )课堂笔记
    李宏毅deep learning(lecturte6)课堂笔记
    李宏毅classification+Logistic Regression(lecturte4+5)课堂笔记
    李宏毅Gradient Descent(lecturte3)课堂笔记
    02.get-post.php
    02.get-post
    01.php基础语法和JS区别.php
    11.子访问父
    10.父访问子--(children+refs)
    9.组件通讯(子传父)自定义事件
  • 原文地址:https://www.cnblogs.com/charlypage/p/8908133.html
Copyright © 2020-2023  润新知