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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now