Use property user.home in java tests


I’m trying to test an export function in my code, and I’m using for that the following Java property:
This leads me to /home/runner.

Before running any test, I run the following commands:
mkdir /home/runner/BooksExports
chmod 777 -R /home/runner/BooksExports
This one works perfectly.

But when the test runs, I get the following error: /home/runner\BooksExports\Toto.docx (Permission denied)
at java.base/ Method)
at java.base/
at java.base/
at java.base/
at com.jher.nid_aux_histoires.export.ExportDocx.buildWordFile(
at com.jher.nid_aux_histoires.export.ExportDocx.launchGeneration(
at com.jher.nid_aux_histoires.service.impl.ExportServiceImpl.export(
at com.jher.nid_aux_histoires.service.impl.ExportServiceImpl.lambda$exportBook$0(
at java.base/

This is the code where I get the error:

		File outputFile = new File(outputFilePath);
		try (OutputStream out = new FileOutputStream(outputFile)) { // error occurs here
		} catch (IOException e) {

I can’t figure out why I’m not able to create this file. Maybe I just can’t do that because it’s not allowed…
Does anyone has an idea ?


Looks like your test is trying to create a file named runner\BooksExports\Toto.docx in /home/. Note that the backslashes aren’t directory separators on Linux! :wink:

Thanks for your answer ! You’re right, I had to update my folder separators.

1 Like