🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #268

Re: location of jar file

#268
From: Magnus
Date: Fri, 20 Oct 2006 20:23
30 lines
2143 bytes
Oliver wrote:
> Hi,
> 
> i have a question concerning the location of the jar file.
> In Delphi there is the application object, and the property 
> ExeName gives the location of the exe. In Java there is no 
> application object. But i still would like to know where the jar
>  file is located.
> 
> At the moment im using the following approach:
> - my installation routine writes an environment variable (content: the path into which the installation writes the jar)
> - my program reads this environment variable 
> 
> This works, but i do not really like this approach.
> What i really would appreciate is an information from the class
>  itself (where it is located) - without any foreign info (such 
> as environment variable).
> 
> At the moment my jar file doesnt know where it is, it needs somebody else to tell him :)
> 
I'm not sure if this solves the problem but when I run the following:
     Properties prop = new Properties();
     prop = System.getProperties();
     String dir=prop.getProperty("user.dir");
     System.out.println("dir="+dir);

the "user.dir" property display where I run my program

To see all properties:
     prop.list(System.out);
Technical Details
Message-ID: <45393026$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4538af7b$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,f288e71066ccfddf
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Fri, 20 Oct 2006 16:23:07 -0400
From: Magnus <magnus_bjorkman@yahoo.com>
User-Agent: Thunderbird 1.5.0.7 (Windows/20060909)
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: location of jar file
References: <4538af7b$1@newsgroups.borland.com>
In-Reply-To: <4538af7b$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 24.149.234.69
Message-ID: <45393026$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1161375782 24.149.234.69 (20 Oct 2006 13:23:02 -0700)
Lines: 32
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail