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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

719 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