Change current directory

Posted on 1999-07-14
Medium Priority
Last Modified: 2009-07-29
How to change the current directory through java.
Question by:rameshg21

Expert Comment

ID: 1246012

 Try the following...

  Properties p = System.getProperties();
  p.put( "user.dir" , "c:\\mydirectory");

 Sankar S.

Accepted Solution

hsk0 earned 150 total points
ID: 1246013
A known limitation of the JDK.
You need to slip into native code.
Easy with Microsoft's JVM and J/Direct:
Use the Win32 API SetCurrentDirectory() via J/Direct.
In another JVM, write a native function
    public static native int setCurrentDirectory(String dirName);
and call SetCurrentDirectory() in the native code.

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month3 days, 9 hours left to enroll

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question