Solved

How can I find from a Java application which is the name of Windows directory (default it is c:\windows...but it can be different)?

Posted on 2011-09-26
4
215 Views
Last Modified: 2012-05-12
How can I find from a Java application which is the name of Windows directory (default it is c:\windows...but it can be different)?
0
Comment
Question by:ionutcib
  • 2
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 36598339
Yes, it can be different. Try the following (not guaranteed to work with every runtime)
String winDir = System.getEnv("WINDIR");

Open in new window

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36598879
You create a file - and then use getAbsolutePath()
This should work on all systems.
See example here

http://www.roseindia.net/java/java-get-example/get-CWD.shtml
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36599014
As you see in the above example you of course do not create any file on the actual file system so you don't comtaminatte it with extra files- you just create File object in your java code - so it is a good clean method of finding working directory on any system
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36599092
:)

>>http://www.roseindia.net/java/java-get-example/get-CWD.shtml

is something quite different, that incidentally can be got a lot more easily with
String cwd = System.getProperty("user.dir");

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ejb mdb examples 1 19
Netbeans and org.apache.commons.lang3 issue 3 22
Virtual box guest operating system will not start 15 49
Cant Extend Laptop screen 6 55
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

679 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