How to get the current working directory in Java
Written on January 10, 2010 at 9:33 am by
mkyong
The current working directory is the root folder of where your current Java project is running, it can be retrieve by using the system property function.
String workingDir = System.getProperty("user.dir");
Example
package com.mkyong.io; public class App{ public static void main (String args[]) { String workingDir = System.getProperty("user.dir"); System.out.println("Current working directory : " + workingDir); } }
Output
Current working directory : E:\workspace\HibernateExample
This article was posted in Java category.
All Java Tutorials
- Java Core Technology - Java RegEx, Java XML, Java I/O, Java Misc
- J2EE Frameworks - Hibernate, Spring 2.5, Spring MVC, Struts 1.x, Struts 2.x
- Build Tools - Maven, Archiva
- Unit Test - jUnit, TestNG
- Client Scripts - jQuery
[...] http://www.mkyong.com/java/how-to-get-the-current-working-directory-in-java/ [...]
nice tip, i’ve subscribed to your rss.
thanks for sharing