title: When I compile this is what I get: unreported exception java.lang.NoSuchFieldException; must be caught or declared to be thrown
body: <p>I'm trying to create a chess program on the using the GridWorld case study. You may or may not know what that is, but that is irrelevant to my problem. I've only been coding in java for about a year now in my AP computer science class, so I'm relatively new at this. What I am trying to to is convert a string to a color. I have looked it up online and in numerous places I have found this code:</p>
  
  <pre><code>Field field = Color.class.getField("YELLOW");
  Color chosen = (Color)field.get(null);
  </code></pre>
  
  <p>I would also like to use a variable instead of "YELLOW", so this is the code that I would like to use.</p>
  
  <pre><code>Field field = Color.class.getField("chosenColor");
  Color chosen = (Color)field.get(null);
  </code></pre>
  
  <p>But it does not work, and I don't know why. The message that I get is the title of this question. I have no idea what it means, and quite honestly I'm not all familiar with the field class, so that could be the root of my issue, but I'm just not sure. I will post my code, and I hoping that you can either help me with this error, or give me another way to convert strings to colors.</p>
  
  <p>Like I said, I'm relatively new, so it would be great if you could use smaller words that my limited coding knowledge can understand.</p>
  
  <pre><code>package framework.info.gridworld;
  
  import info.gridworld.actor.ActorWorld;
  import info.gridworld.actor.*;
  import info.gridworld.grid.*;
  
  
  import java.awt.Color;
  import java.util.*;
  import java.lang.reflect.Field;
  /**
   * Play a game of chess! Simple, yet oh so complicated.
   * 
   * @author M.A.Williams
   * Version one. Started: 5-15-2014 Finished: N/A
   */
  public class ChessRunner
  {
      public static void main(String[]args)
      {
          Scanner in= new Scanner(System.in);
  
          System.out.println("Pick from one of these colors! \nBlue \nCyan\nGreen\nMagenta\nOrange\nPink\nRed\nWhite\nYellow");
          System.out.println("Do not choose Black!!!");
          String chosenColor=in.next();
          chosenColor=chosenColor.toUpperCase();
  
          while(chosenColor.equals("BLACK"))
          {
              System.out.println("I told you not to choose Black! Choose a different color!");
  
              chosenColor=in.next();
              chosenColor=chosenColor.toUpperCase();
          }
  
          Field field = Color.class.getField("YELLOW");
          Color chosen = (Color)field.get(null);
  
          ActorWorld chessWorld= new ActorWorld();
  
          Bug playerKing=new Bug(chosen);
  
          chessWorld.add(new Location(7, 8), playerKing);
  
          chessWorld.show();
      }
  }
  </code></pre>