eclipse中的System.getProperty("user.dir")

eclipse中的System.getProperty("user.dir")


1、在Java Application中,上述中的获取的是Java项目的路径

(1)运行源码

/**
 * 
 */
package com.you.test;

/**
 * @author YouHaiDong
 *
 */
public class Property 
{
	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{
		String path = System.getProperty("user.dir");
		System.out.println("Java Application项目路径:" + path);
	}

}

(2)运行结果

项目路径:E:EclipseworkspaceYou

2、在Java Web项目中,获取的是eclipse中的安装目录路径




原文地址:https://www.cnblogs.com/hzcya1995/p/13314698.html