Article View: borland.public.jbuilder.java.api
Article #624Re: current directory
From: John McGrath TeamB
Date: Wed, 28 May 2003 01:13
Date: Wed, 28 May 2003 01:13
52 lines
2763 bytes
2763 bytes
On Mon, 26 May 2003 12:35:42 +0300, terhi wrote:
> is it possible to change the current directory of the application?
No.
> My java program prints to PDF-writer. PDF-Writer asks the path for
> the pdf-file and changes the current directory to that location.
> After printing, my java program's current directory has also been
> changed to that given path and that couses problems. How can I
> change it back? Current directory is different than "User.dir",
> getAbsolutePath() and getCanonicalPath. I think it is some how
> kept in the memory.
Windows keeps track of that and I think using the Windows file open
dialog can change the setting.
I think it is generally not a good idea write code that depends on the
current directory. Instead, get the value of "user.dir" when you start
the application and then explicitly specify that on all file opens.
You will save yourself a lot of trouble that way.
> I have tried to use Dos commands, but they did not work.
That would change the current directory for the sub-process, but not
for the process that spawned it.
> Should I try to use win32 api functions from java? Is that the
> only way?
That would be the only other choice besides writing your code to not
depend on the current directory.
> Is it even possible?
It should be using JNI.
> Can I use them directly from the java code without creating a
> c-code where to call win32 api?
No, you will need to write a JNI wrapper. Of course, it is possible
that someone has done that already, so you might avoid writing the code
yourself.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<MPG.193dd750fc313c0598bfb6@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!38.144.126.76.MISMATCH!feed2.newsreader.com!newsreader.com!newsfeed.media.kyoto-u.ac.jp!out.nntp.be!propagator2-sterling!in.nntp.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3ed1dfee@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,d0bad3e1a5d1d949 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2003-05-27 18:39:26 PST From: John McGrath [TeamB] <ng-b@JPMcGrath.net> Newsgroups: borland.public.jbuilder.java.api Subject: Re: current directory Date: Tue, 27 May 2003 21:13:38 -0400 Message-ID: <MPG.193dd750fc313c0598bfb6@newsgroups.borland.com> References: <3ed1dfee@newsgroups.borland.com> X-Newsreader: MicroPlanet Gravity v2.60 NNTP-Posting-Host: 151.197.11.12 X-Trace: newsgroups.borland.com 1054084416 151.197.11.12 (27 May 2003 18:13:36 -0700) Lines: 52 X-Authenticated-User: jpmcgrath Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!38.144.126.76.MISMATCH!feed2.newsreader.com!newsreader.com!newsfeed.media.kyoto-u.ac.jp!out.nntp.be!propagator2-sterling!in.nntp.be!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail