🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Locating an INI file

#7480
From: Anton Pavlik
Date: Thu, 21 Jun 2001 06:11
33 lines
1882 bytes
Mio Nino Marquez wrote:

> Java newbie here. :)
>
> I've written a bunch of class under a package (say MyLib). One class needs
> to read an INI file for some configuration settings. Initially, I have hard
> coded the location of the file. But now, I don't want it to be hard coded.
>
> So I guess my question is, how do I know the location of the class /
> package? Code snippets would definitely be helpful.
>
> PS: In Delphi I can use the ExtractFilePath(application.exename) to get the
> location of the exe file. i'm looking for something similar in java.

try to read user.dir system property

import java.util.*;

public class UserDir {
 public static void main(String[] aa) {
   String key;
   try {
    Properties systemProperties = System.getProperties();
    System.out.println("Exec dir: " +systemProperties.getProperty("user.dir"));

   } catch (Exception e) {}
 }
}

--
Best wishes
Anton
sshake(a)hotmail.zp.ua
Technical Details
Message-ID: <3B319013.44E250DB@hotmail.zp.ua>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!193.174.75.178!news-fra1.dfn.de!news-lei1.dfn.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3b317205_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,52be12fbe909d3e9
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-06-20 23:39:04 PST
Message-ID: <3B319013.44E250DB@hotmail.zp.ua>
Date: Thu, 21 Jun 2001 09:11:31 +0300
From: Anton Pavlik <sshake@hotmail.zp.ua>
Reply-To: sshake@hotmail.zp.ua
X-Mailer: Mozilla 4.72 [en] (WinNT; I)
X-Accept-Language: ru,en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: Locating an INI file
References: <3b317205_1@dnews>
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 212.8.32.162
X-Trace: dnews 993103765 212.8.32.162 (20 Jun 2001 23:09:25 -0700)
Lines: 35
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!193.174.75.178!news-fra1.dfn.de!news-lei1.dfn.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews