Article View: borland.public.jbuilder.java.api
Article #504Re: current directory
From: Alejandro Guzman
Date: Tue, 08 Jul 2003 18:35
Date: Tue, 08 Jul 2003 18:35
59 lines
3198 bytes
3198 bytes
I found the answer of my question in the following link: http://forum.java.sun.com/thread.jsp?forum=31&thread=371174 "John McGrath [TeamB]" <ng-b@JPMcGrath.net> escribi๏ฟฝ en el mensaje news:MPG.193dd750fc313c0598bfb6@newsgroups.borland.com... > 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:
<3f0b0f79@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!demon!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3ed1dfee@newsgroups.borland.com> <MPG.193dd750fc313c0598bfb6@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 1089d0,d0bad3e1a5d1d949 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2003-07-08 11:40:26 PST From: "Alejandro Guzman" <aeguzmanv@hotmail.com> Newsgroups: borland.public.jbuilder.java.api References: <3ed1dfee@newsgroups.borland.com> <MPG.193dd750fc313c0598bfb6@newsgroups.borland.com> Subject: Re: current directory Date: Tue, 8 Jul 2003 14:35:50 -0400 Lines: 61 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 NNTP-Posting-Host: 64.241.170.26 Message-ID: <3f0b0f79@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1057689465 64.241.170.26 (8 Jul 2003 11:37:45 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!demon!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail