System.getProperty("user.dir")

java有关操作系统的一些属性

package com.ccm.codebase.temporary;

/*
 获得当前类的完整路径。最后一句
 */

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;


/**
 *
 java.version          Java 运行时环境版本
 java.vendor         Java 运行时环境供应商
 java.vendor.url         Java 供应商的 URL
 java.vm.specification.version         Java 虚拟机规范版本
 java.vm.specification.vendor         Java 虚拟机规范供应商
 java.vm.specification.name         Java 虚拟机规范名称
 java.vm.version         Java 虚拟机实现版本
 java.vm.vendor         Java 虚拟机实现供应商
 java.vm.name         Java 虚拟机实现名称
 java.specification.version         Java 运行时环境规范版本
 java.specification.vendor         Java 运行时环境规范供应商
 java.specification.name         Java 运行时环境规范名称
 os.name         操作系统的名称
 os.arch         操作系统的架构
 os.version         操作系统的版本
 file.separator         文件分隔符(在 UNIX 系统中是“ / ”)
 path.separator         路径分隔符(在 UNIX 系统中是“ : ”)
 line.separator         行分隔符(在 UNIX 系统中是“ /n ”)

 java.home         Java 安装目录
 java.class.version         Java 类格式版本号
 java.class.path         Java 类路径
 java.library.path          加载库时搜索的路径列表
 java.io.tmpdir         默认的临时文件路径
 java.compiler         要使用的 JIT 编译器的名称
 java.ext.dirs         一个或多个扩展目录的路径
 user.name         用户的账户名称
 user.home         用户的主目录
 user.dir

 */

public class JavaSystemProperty {

    public static void main(String[] args) throws MalformedURLException, URISyntaxException {

        System.out.println("java.home : " + System.getProperty("java.home"));

        System.out.println("java.class.version : " + System.getProperty("java.class.version"));

        System.out.println("java.class.path : " + System.getProperty("java.class.path"));

        System.out.println("java.library.path : " + System.getProperty("java.library.path"));

        System.out.println("java.io.tmpdir : " + System.getProperty("java.io.tmpdir"));

        System.out.println("java.compiler : " + System.getProperty("java.compiler"));

        System.out.println("java.ext.dirs : " + System.getProperty("java.ext.dirs"));

        System.out.println("user.name : " + System.getProperty("user.name"));

        System.out.println("user.home : " + System.getProperty("user.home"));

        System.out.println("user.dir : " + System.getProperty("user.dir"));

        System.out.println("===================");

        System.out.println("package: "+ JavaSystemProperty.class.getPackage().getName());

        System.out.println("package: "+ JavaSystemProperty.class.getPackage().toString());

        System.out.println("=========================");

        String packName = JavaSystemProperty.class.getPackage().getName();

        /*URL packurl = new URL(packName);

        System.out.println(packurl.getPath());*/

        URI packuri = new URI(packName);

        System.out.println(packuri.getPath());

        //System.out.println(packuri.toURL().getPath());

        System.out.println(packName.replaceAll("//.", "/"));

        System.out.println(System.getProperty("user.dir")+"/"+(JavaSystemProperty.class.getPackage().getName()).replaceAll("//.", "/")+"/");
    }
}

java.home : C:\Program Files\Java\jdk1.8.0_144\jre
java.class.version : 52.0
java.class.path : C:\Program Files\Java\jdk1.8.0_144\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_144\jre\lib\rt.jar;D:\Projects\codebase\target\classes;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.2.2\lib\idea_rt.jar
java.library.path : C:\Program Files\Java\jdk1.8.0_144\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Java\jdk1.8.0_144\bin;C:\Program Files\Java\jdk1.8.0_144\jre\bin;D:\Software\FortuneLantern\apache-ant-1.10.1-bin\apache-ant-1.10.1\bin;D:\Program Files (x86)\Launch4j\bin;D:\Program Files\Git\cmd;D:\Program Files\Git LFS;C:\WINDOWS\System32\OpenSSH;D:\Software\FFMeng\ffmpeg-2.8.1-win64-static\bin;D:\Software\Java\maven\apache-maven-3.5.3\bin;D:\Software\Java\apache-tomcat-9.0.8\bin;D:\Software\Java\apache-tomcat-9.0.8\lib;D:\Program Files\Python27;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\WINDOWS\system32\config\systemprofile.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;D:\Program Files\nodejs;D:\FFMpeg\yasm\vsyasm-1.3.0-win64;D:\Program Files (x86)\gifsicle;D:\Program Files\TortoiseGit\bin;D:\Software\protobuf\protobuf-3.6.1\x64VS2015\Debug;D:\Program Files\jibx;C:\Users\black\AppData\Local\Microsoft\WindowsApps;D:\Software\FortuneLantern\apache-ant-1.10.1-bin\apache-ant-1.10.1\bin;C:\Users\black\AppData\Local\GitHubDesktop\bin;C:\Users\black\AppData\Local\Microsoft\WindowsApps;D:\Software\FFMeng\ffmpeg-20180529-ea0010b-win64-static\bin;D:\Program Files (x86)\Slot Constructor\bin;D:\Program Files (x86)\Slot Constructor\plugins;C:\Users\black\AppData\Roaming\npm;;.
java.io.tmpdir : C:\Users\black\AppData\Local\Temp
java.compiler : null
java.ext.dirs : C:\Program Files\Java\jdk1.8.0_144\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
user.name : black
user.home : C:\Users\black
user.dir : D:\Projects\codebase
===================
package: com.ccm.codebase.temporary
package: package com.ccm.codebase.temporary
=========================
com.ccm.codebase.temporary
com.ccm.codebase.temporary
D:\Projects\codebase/com.ccm.codebase.temporary/

你可能感兴趣的:(System.getProperty("user.dir"))