JavaFX: ClassNotFoundException for imported class in FXML
<p>I'm trying to create a textfield with a title embedded in the field border like:</p>

<p><a href="https://i.stack.imgur.com/qH1Se.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qH1Se.png" alt="enter image description here"></a></p>

<p>Following the solution posted <a href="https://stackoverflow.com/a/14874195/4731712">here</a> I've created a .java file called <code>TitledBorder.java</code> within my <code>src&gt;main&gt;java</code> directory. My FXML is in the <code>src&gt;main&gt;resources</code> directory and I've added:</p>

<p><code>&lt;?import TitledBorder?&gt;</code> at the top and it shows no error like:
<a href="https://i.stack.imgur.com/Wi9pG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wi9pG.png" alt="enter image description here"></a></p>

<p>I then added this code to the FXML </p>

<pre><code>&lt;HBox prefHeight="100.0" prefWidth="200.0"&gt;
    &lt;children&gt;
      &lt;TitledBorder title="Email" &gt;
        &lt;TextField fx:id="emailField" prefHeight="44.0" prefWidth="143.0" /&gt;
      &lt;/TitledBorder&gt;
    &lt;/children&gt;
&lt;/HBox&gt;
</code></pre>

<p>and it shows no error either. I then launch my main method which is in a class also in src>main>java but it gets an error in the .fxml saying <code>javafx.fxml.LoadException: 
/C:/Users/ME/Documents/Automation/target/classes/demofxml.fxml</code></p>

<p>and</p>

<pre><code>Caused by: java.lang.ClassNotFoundException
    at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2899)
</code></pre>

<p>I'm not sure why it references "/target/classes/..." as opposed to "/src/main/java/...". </p>

<p>This is the only FXML example I've found so I'm confused why I'm getting an error upon compiling, yet no errors are shown prior? Removing all reference to <code>TitledBorder</code> allows all my code to function/compile properly. Since its in the src package I use this code in FXML to connect w/ controller <code>fx:controller="loadController"&gt;</code>. CSS is added properly too.</p>

<p>Thoughts?</p>