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
213 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

778 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