title: Netbeans 8.0.2 Clean and Build then Run results in old code being run
body: <p>I'm new to NetBeans and Java.  I'm using NetBeans to build and run a Java Swing project for school.</p>
  
  <p>I wrote my code in NetBeans and saved it.  Compiling from command line with <code>javac</code> is successful and the program runs as expected.  If I update the code and repeat the process from CLI, the new changes are reflected as expected.</p>
  
  <p>If I make a code change in NetBeans, and <code>Clean and Build</code> (e.g. by pressing Shift+F11), then run from in NetBeans (e.g. by F6), the changes are <strong>not</strong> reflected.  No errors, I just get a <code>BUILD SUCCESSFUL</code> notification in Output.  But an older version of the application will run with no changes reflected.</p>
  
  <p>I get around it by building from CLI but that's getting old really fast, it would be nice to be able to run from w/in the IDE.</p>
  
  <p>Following is some context code.  It runs as desired.  As an example of my problem, note the button initialization in File 2.  If I change the ctor string arg, the change will not be reflected when I clean, build, and run in NetBeans, (or if I just build and run without clean).  However, it will be reflected if run from command line.</p>
  
  <p>File 1:</p>
  
  <pre><code>/* pkg &amp; import statements */
  
  public class Project1Part1 {
  
      public static void main(String[] args) {
          System.out.println("Attempting to build frame...");
          buildFrame();
      }
  
      public static void buildFrame()
      {
          JFrame frame = new JFrame("Project 1, Part 1");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          GuiPanel guiPanel = new GuiPanel();
          frame.setContentPane(guiPanel);
          frame.setSize(640, 360);
          frame.setVisible(true);
          System.out.println("Frame built.");
      }
  }
  </code></pre>
  
  <p>File 2:</p>
  
  <pre><code>/* pkg and import statements */
  
  public class GuiPanel extends JPanel {
  
      public GuiPanel()
      {
          LayoutManager layoutMgr = new FlowLayout();
          setLayout(layoutMgr);
  
          Dimension buttonSize = new Dimension(150, 20);
          JButton cardPickerButton = new JButton("Card Picker");
          cardPickerButton.setPreferredSize(buttonSize);
          add(cardPickerButton);
      }
  }
  </code></pre>
  
  <p><strong>Update:</strong>
  I upgraded my version of Ant from 1.9.4 to 1.9.6 as a shot in the dark based on other postings I saw, it made no difference.</p>
  
  <p><strong>Update 2:</strong>
  I was using only the <code>Build</code> and <code>Clean and Build</code> options, which are not for compiling an application to run within the IDE.  When a file is saved, NetBeans automatically compiles the project by default, as per:
  <a href="https://netbeans.org/kb/docs/java/quickstart.html#run" rel="nofollow">the NetBeans documentation</a>.  Likewise, if the user selects <code>Run</code>, all unsaved files will automatically be saved and compiled before NetBeans runs the application.  My problem was that I'm used to Clean and Build meaning something different, so I was running a Clean and Build every time I wanted to run the application in the IDE.  Once the <code>Clean and Build</code> or even the <code>Build</code> option is chosen in NetBeans, I haven't found a way to force recompilation for execution within the IDE other than making a trivial change to allow a resave of some file in the project.</p>
  
  <p><strong>Update 3:</strong>
  Adding my project's <code>build.xml</code> by request.  I removed commented sections for readability.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project name="Project1Part1" default="default" basedir="."&gt;
      &lt;description&gt;Builds, tests, and runs the project Project1Part1.&lt;/description&gt;
      &lt;import file="nbproject/build-impl.xml"/&gt;
  &lt;/project&gt;
  </code></pre>