I'm trying to change the java working directory, which means, I'm trying to change user.dir
property.
For instance, the code below will create a file called foo in my user.dir
directory.
FileOutputStream out = new FileOutputStream("foo.txt");
out.write("foo".getBytes());
out.close();
If I want this file to be created in another directory, that is not the dir that I have ran java command I need to use System.setProperty
, in my case I want
System.setProperty("user.dir", System.getProperty("jboss.server.temp.dir"));
But this doesn't work, I think it's because I'm using FileOutputStream
instead of File
If I run WildFly through eclipse plugin, I can set a working directory path, this way everything works as expected. See the image
I've tried to put -Duser.dir=%JBOSS_HOME%\standalone\tmp
inside standalone.bat
script, but doesn't affect at all.
The actual working directory is %JBOSS_HOME%\bin
, the place where java -jar
is called
My question: How can I change the working directory for java running on wildfly and working for FileOutputStream
?