Chris Woods writes:
 > Paul Kinnucan wrote:
 > 
 > > Hi all,
 > > 
 > > Is there any way to set the current working directory in Java.  I want to be able 
 >to change the beanshell's current directory to the directory of the current source 
 >buffer so I don't need to specify the full path of the source file to be compiled. 
 >The beanshell has a cd command but it does not appear to work.
 > > 
 > > - Paul
 > 
 > 
 > I was able to successfully use the cd("/some/directory/path") command 
 > from a bsh Interpreter prompt. Beanshell's cd() command is just a bsh 
 > script that appears to simply set the `bsh.cwd' property, at which point 
 > I suspect there is code in Beanshell that resets the Interpreter's 
 > "context" to the new value of the bsh.cwd property.
 > 
 > I haven't looked at the elisp for the bsh interface in JDE, so I don't 
 > know how you'd make that happen in that context. However, it seems as if 
 >   it should work by calling Beanshell's cd() command, or possibly by 
 > setting the bsh.cwd property directly.
 > 

I've already tried this and it does not work. Specifically, I tried the
equivalent of:

cd c:/foo
javac Bar.java

in the beanshell and the compiler reports a "Bar.java not found" error, even
though the Beanshell's pwd(); command reports the cwd as c:/foo.


 > I did a little digging in java.io.File as well, and it does sport 
 > "isDirectory()" methods, and allow creation of a new File object that is 
 > actually a directory rather than a file. However, it appears as if the 
 > actual changing of the application's cwd context is left to the 
 > implementation itself.
 > 
 
Yes, unfortuately, that's my impression, too. The problem is I'm not sure
that it's even possible to do the equivalent of cd in Java.

- Paul

Reply via email to