title: JavaFX java.lang.IllegalArgumentException: Can not set javafx.scene.control.Label field sample.Controller.location to java.net.URL
body: <p>My JavaFX application has a Label with an fx:id of <code>location</code>. It is defined in an FXML file. When I try to run the application, I get the following error:</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: Can not set javafx.scene.control.Label field sample.Controller.location to java.net.URL</p>
  </blockquote>
  
  <p>I am using JDK 12 with JavaFX 11.0.2.</p>
  
  <p>I've seen other answers here on SO that say this is caused by a conflicting type for the <code>location</code> Label. For example, it might be declared as a Label in the FXML file but in the Java code it is something else (in this case, java.net.URL). However, as you can see in the code below, I am not using the URL class anywhere.</p>
  
  <p>Changing the fx:id to something else (such as <code>loc</code>) makes the error go away, so <code>location</code> must be a "magic" name.</p>
  
  <p>What is causing this?</p>
  
  <h3>sample.fxml</h3>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.control.Label?&gt;
  &lt;?import javafx.scene.layout.Pane?&gt;
  
  &lt;Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller"&gt;
     &lt;children&gt;
        &lt;Label fx:id="location" layoutX="133.0" layoutY="146.0" text="Output" /&gt;
     &lt;/children&gt;
  &lt;/Pane&gt;
  </code></pre>
  
  <h3>Main.java</h3>
  
  <pre><code>package sample;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  public class Main extends Application
  {
  
      @Override
      public void start(Stage primaryStage) throws Exception
      {
          Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
          primaryStage.setTitle("Hello World");
          primaryStage.setScene(new Scene(root, 400, 275));
          primaryStage.show();
      }
  
  
      public static void main(String[] args)
      {
          launch(args);
      }
  }
  </code></pre>
  
  <h3>Controller.java</h3>
  
  <pre><code>package sample;
  
  import javafx.fxml.FXML;
  import javafx.scene.control.Label;
  
  public class Controller
  {
      @FXML
      Label location;
  
  }
  </code></pre>
  
  <h3>module-info.java</h3>
  
  <pre><code>module MyTest
  {
      requires javafx.controls;
      requires javafx.fxml;
      opens sample;
  }
  </code></pre>