Changing the current working directory in Java?

前端 未结 14 1511
太阳男子
太阳男子 2020-11-22 05:32

How can I change the current working directory from within a Java program? Everything I\'ve been able to find about the issue claims that you simply can\'t do it, but I can\

14条回答
  •  别那么骄傲
    2020-11-22 05:38

    It is possible to change the PWD, using JNA/JNI to make calls to libc. The JRuby guys have a handy java library for making POSIX calls called jna-posix Here's the maven info

    You can see an example of its use here (Clojure code, sorry). Look at the function chdirToRoot

提交回复
热议问题