title: IllegalAccessException: cannot access class C (in module M) because module M does not export C to module N
body: <p>I'm trying to add Maven support to an existing JavaFX project that I have.</p>
  <p>I started by following OpenJFX's <a href="https://openjfx.io/openjfx-docs/#IDE-Intellij" rel="nofollow noreferrer">Getting Started Guide</a>, which teaches you how to compile and run a Hello World JavaFX application with Maven. After I made it, I pasted my project's files in this new project and made the changes needed. My folder strucutre is more or less like this:</p>
  <pre><code>src/main/
    java/
      org.openjfx/
        Main.java
        components/
        controllers/
    resources/org.openjfx/fxml/
  </code></pre>
  <p>To run the project, I use these Maven commands:</p>
  <pre><code>compiler:compile
  javafx:compile
  javafx:run
  </code></pre>
  <p>However, I'm getting this error:</p>
  <p>Exception in Application start method
  Caused by: java.lang.IllegalAccessException: class javafx.fxml.FXMLLoader$ValueElement (in module javafx.fxml) cannot access class org.openjfx.controllers.LoginController (in module org.openjfx) because module org.openjfx does not export org.openjfx.controllers to module javafx.fxml</p>
  <p>Which seems odd, since apparently I'm exporting the stuff in <code>module-info.java</code>:</p>
  <pre class="lang-java prettyprint-override"><code>module org.openjfx {
      requires javafx.controls;
      requires javafx.fxml;
  
      opens org.openjfx to javafx.fxml;
      exports org.openjfx;
  }
  </code></pre>
  <p>I wonder if naming my package <code>org.openjfx</code> was a bad idea and may be causing issues, but I just followed along with the tutorial.</p>
  <p>Below is my <code>pom.xml</code> file, if it's of any relevance:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
           xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
      &lt;artifactId&gt;hellofx&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;maven.compiler.release&gt;11&lt;/maven.compiler.release&gt;
          &lt;javafx.version&gt;13&lt;/javafx.version&gt;
      &lt;/properties&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
              &lt;artifactId&gt;javafx-controls&lt;/artifactId&gt;
              &lt;version&gt;${javafx.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
              &lt;artifactId&gt;javafx-fxml&lt;/artifactId&gt;
              &lt;version&gt;${javafx.version}&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.8.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;release&gt;${maven.compiler.release}&lt;/release&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.openjfx&lt;/groupId&gt;
                  &lt;artifactId&gt;javafx-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;0.0.3&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;mainClass&gt;org.openjfx.App&lt;/mainClass&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>