🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
5 messages
5 total messages Started by terhi Mon, 26 May 2003 09:35
current directory
#618
Author: terhi
Date: Mon, 26 May 2003 09:35
16 lines
1753 bytes
Hello,

is it possible to change the current directory of the application? 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.

I have tried to use Dos commands, but they did not work. Should I try to use
win32 api functions from java? Is that the only way? Is it even possible?
Can I use them directly from the java code without creating a c-code where
to call win32 api?

regards terhi
Re: current directory
#624
Author: John McGrath TeamB
Date: Wed, 28 May 2003 01:13
52 lines
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
Re: current directory
#503
Author: Alejandro Guzman
Date: Mon, 07 Jul 2003 17:32
66 lines
3432 bytes
Hi, I have a little problem using "User.dir" and getCanonicalPath. I'm using
TOMCAT, and I developed a web app (with JBuilder 6.0)  that have to read
information of a file. In my  computer when I call those function I get the
app directory, but when I run the App in the web server, I get other
directory (C:\WINNT\SYSTEM32)...
Does anybody know what wrong ??
What can I do ???

Thank in advance,
Alejandro.


"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
Re: current directory
#504
Author: Alejandro Guzman
Date: Tue, 08 Jul 2003 18:35
59 lines
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
Re: current directory
#505
Author: John McGrath [TeamB]
Date: Wed, 09 Jul 2003 04:17
15 lines
1266 bytes
On 7/8/2003 at 2:35:50 PM, Alejandro Guzman wrote:

> 
> I found the answer of my question in the following link:
> 
> http://forum.java.sun.com/thread.jsp?forum=31&thread=371174

You might find this interesting too:

   http://www.visi.com/~gyles19/fom-serve/cache/391.html

-- 
Regards,

John McGrath  [TeamB]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads