wood burning stoves 2.0*
The moose likes Java in General and the fly likes how to get the window default installation path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to get the window default installation path" Watch "how to get the window default installation path" New topic
Author

how to get the window default installation path

prabhu ganapathylingam
Greenhorn

Joined: Oct 15, 2010
Posts: 8
hi

I am trying to find the window installation path using a java program. is there any way to find the path. help me
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

Moving to Java in General.

What do you mean with Windows installation path? The folder in which Windows is installed? Then use System.getenv("WINDIR"). On my machine that returns C:\WINDOWS.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

System.getenv("windir") ? Not sure it applies to all Windows versions...


[My Blog]
All roads lead to JavaRanch
prabhu ganapathylingam
Greenhorn

Joined: Oct 15, 2010
Posts: 8
hi,
thanks for reply. I want to find the path while installing the software where it is going to installed. how to find this.


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

Your program won't know where you will install it. The installer itself probably will; for instance, InnoSetup uses {app} for the application installation folder.

Why do you need this?
prabhu ganapathylingam
Greenhorn

Joined: Oct 15, 2010
Posts: 8
I have created an executable file. the user can install it where ever he wants it may be c:,d: or something
i want to find the path where the application is installed
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

You haven't created an executable file; you've created an executable JAR. Small difference but important enough to mention. JAR files are more limited than executables (e.g. no icon).

Technically it isn't possible to get the path of a JAR file. There are a few tricks however; search for my posts in this forum. Look for ProtectionDomain as search word.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get the window default installation path