🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #2686

Re: Working Directory

#2686
From: Preston L. Bannister
Date: Thu, 01 Jun 2000 00:00
36 lines
1992 bytes
"mprader" <michael.praderNOmiSPAM@zurich.com.invalid> wrote in message news:2cde0dd5.6e2366b4@usw-ex0108-062.remarq.com...
> I try to start a Java Application from JBuilder.
> My problem is, that I have config files which I have to
> read at the start of the application. Furthermore there are
> some other files I have to read relative to that path.
> My project isn't in the same folder as the config file,
> therefore I have to start my application in that folder.
> But I didn't find a way to specifiy in JBuilder where to
> start my application.

JBuilder does something weird with the current directory,
so even if you could start your application from the other
directory, it's not clear that you would find your files.

Instead be explicit on startup:

  java -Dmyapp.config=c:\myapp\config ....

and in your application:

  String pathConfig = System.getProperty("myapp.config");
  File fileConfig = new File(pathConfig);

  File fileConfigFoo = new File(fileConfig,"foo");
  InputStream = new FileInputStream(fileConfigFoo);

If you want the current directory from which you started:

  String path = System.getProperty("user.dir");

It works for me... :)

--
Preston L. Bannister
preston@home.com
http://members.home.com/preston
Technical Details
Message-ID: <ktAZ4.208319$bm.1258336@news1.alsv1.occa.home.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <2cde0dd5.6e2366b4@usw-ex0108-062.remarq.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,13dfe660ec9827b0
X-Google-Attributes: gid1089d0,public
From: "Preston L. Bannister" <preston@home.com>
Subject: Re: Working Directory
Date: 2000/06/01
Message-ID: <ktAZ4.208319$bm.1258336@news1.alsv1.occa.home.com>
X-Deja-AN: 629999094
References: <2cde0dd5.6e2366b4@usw-ex0108-062.remarq.com>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4029.2901
X-Complaints-To: abuse@home.net
X-Trace: news1.alsv1.occa.home.com 959894480 24.1.136.62 (Thu, 01 Jun 2000 14:21:20 PDT)
Organization: @Home Network
X-MSMail-Priority: Normal
NNTP-Posting-Date: Thu, 01 Jun 2000 14:21:20 PDT
Newsgroups: borland.public.jbuilder.java.api