title: Java local variable accessed from within inner class; needs to be declared final, why it works in NetBeans?
body: <p>In my Java app, there is a method and it has the following code:</p>
  
  <pre><code>JButton Button = new JButton(Content);
  Button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
          doSomething(Button.getText());
      }
  });
  </code></pre>
  
  <p>It compiles and works fine from NetBeans 8.1, but today when I tried to compile the project from command line, it gave me the following error: </p>
  
  <blockquote>
    <p>local variable Button is accessed from within inner class; needs to be declared final</p>
  </blockquote>
  
  <p>My question is: why the same code complies and works fine from NetBeans 8.1 but can't compile in command line?</p>
  
  <p>My command line Java version is: 1.8.0_77</p>
  
  <p>And my NetBeans Java version is: 1.8.0_65</p>
  
  <p>That shouldn't matter, so why NetBeans doesn't consider it an error?</p>
  
  <p>Edit : Woo, BIG SURPRISE for me, I just did a check on javac :</p>
  
  <p>C:\Users\USER>java -version
  java version "1.8.0_77"</p>
  
  <p>C:\Users\USER>javac -version
  javac 1.7.0_40</p>
  
  <p>Wait a minute, I'm 100% confused big time, first I never knew there is a "javac -version" command, I thought "java -verison" will tell me both java and javac, and I assume they are the same, second, when I installed Java, I thought the installer will update it automatically, and javac is part of java, so it should be internally consistent, but it definitely is NOT, so how can my java -version being different from my javac -version ? In other words how can I trust Oracle to install my java and javac at the same time, if it doesn't do the job, does that mean everytime I update Java, I need to somehow install my javac by hand ? I've never done that, so why and how could this happen ?</p>