title: Trying to set .policy java file with denied access network and access other files than source - mvn surefire plugin-Error while executing forked tests
body: <p>Always I read your helpful post, but this is my first time that I didn't find a solution for my case and I am forced to write this post and asking you for your help.</p>
  <p>I have problem with set up .policy java file to block access for network and files. Of course I read this 2 posts:</p>
  <p><a href="https://stackoverflow.com/questions/4645588/how-to-disable-all-network-connections-in-java-on-windows-server-2008">How to disable all network connections in Java</a></p>
  <p><a href="https://stackoverflow.com/questions/25681670/disable-internet-access-for-jvm">Disable &quot;internet access&quot; for JVM?</a></p>
  <p>and many more other posts about this problem (this two I think are the closest to my case).</p>
  <p>For beginning I tried to put in .policy file anything that will be worked when I will start command <code>mvn clean install</code> or <code>mvn test</code>.</p>
  <p>So in my .policy file I've put the same code like in first link:</p>
  <pre><code>grant {
   permission java.io.FilePermission &quot;&lt;&lt;ALL FILES&gt;&gt;&quot;, &quot;read,write,execute,delete&quot;;
      permission java.util.PropertyPermission &quot;*&quot;, &quot;read,write&quot;;
      permission java.lang.RuntimePermission &quot;*&quot;;
      permission java.net.NetPermission &quot;*&quot;;
      permission java.lang.reflect.ReflectPermission &quot;*&quot;;
      permission java.net.SocketPermission &quot;*&quot;;
  };
  </code></pre>
  <p>And after any maven command I received:</p>
  <pre><code>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project zadanie2: There are test failures.
  [ERROR]
  [ERROR] Please refer to E:\projects\exampleProject\target\surefire-reports for the individual test results.
  [ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
  [ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
  [ERROR] Command was cmd.exe /X /C &quot;&quot;C:\Program Files\Java\jdk-18.0.1.1\bin\java&quot; -jar C:\Users\xxx\AppData\Local\Temp\surefire2284009761624596034\surefirebooter17583345691919401837.jar C:\Users\xxx\AppData\Local\Temp\surefire2284009761624596034 2022-08-12T22-27-35_585-jvmRun1 surefire10226365412794941225tmp surefire_0532462194274044084tmp&quot;
  [ERROR]
  [ERROR] Error while executing forked tests.Error while executing process.Cannot run program &quot;cmd.exe&quot; (in directory &quot;E:\projects\exampleProject&quot;): Malformed argument has embedded quote: &quot;C:\Program Files\Java\jdk-18.0.1.1\bin\java&quot; -jar C:\Users\xxx\AppData\Local\Temp\surefire2284009761624596034\surefirebooter17583345691919401837.jar C:\Users\xxx\AppData\Local\Temp\surefire2284009761624596034 2022-08-12T22-27-35_585-jvmRun1 surefire10226365412794941225tmp surefire_0532462194274044084tmporg.apache.maven.surefire.shade.org.apache.maven.shared.utils.cli.CommandLineException: Error while executing process.
  [ERROR]         at org.apache.maven.surefire.shade.org.apache.maven.shared.utils.cli.Commandline.execute(Commandline.java:412)
  [ERROR]         at org.apache.maven.plugin.surefire.booterclient.lazytestprovider.OutputStreamFlushableCommandline.execute(OutputStreamFlushableCommandline.java:65)
  [ERROR]         at org.apache.maven.surefire.shade.org.apache.maven.shared.utils.cli.CommandLineUtils.executeCommandLineAsCallable(CommandLineUtils.java:229)
  </code></pre>
  <p>I also tried option from second link, but maven always needed new permission and I gave it, gave it and for last info was problem with converting AccessException into IOException.</p>
  <p>Still same thing - is not working.</p>
  <p>Do you have any example .policy file that for sure will be working with my API? Or any suggestions how I can solve it? What to change? What to do to block any network and file access other than necessary, for API?</p>
  <p>I will be very grateful guys!</p>