?
Solved

Change current directory

Posted on 1999-07-14
2
Medium Priority
?
368 Views
Last Modified: 2009-07-29
How to change the current directory through java.
0
Comment
Question by:rameshg21
[X]
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
2 Comments
 
LVL 1

Expert Comment

by:sankars98
ID: 1246012

 Try the following...

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

 Sankar S.
0
 

Accepted Solution

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

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