public class Test {

public static void main(String[] arg){
	Console console=System.console();	   	     
	String chessPiece="";
	int rowEnd=0;	
	char columnEnd = ' ';   

       System.out.println("what piece do you want to move?");  
	   System.out.println("where do you want to move it to?(type column letter)");
	   String input=console.readLine();
	   System.out.println("where do you want to move it to?(type row number)");

if i put this into a notepad and launch it, it works, but with eclipse it tells me:

what piece do you want to move?
Exception in thread "main" java.lang.NullPointerException
	at Test.main(


Is the console variable null?
Read the API doc for the System console() method. Can that method return null?

I don't know why your IDE doesn't support the console method.

it is hard to say norm1. why wouldnt eclipse support Console console=System.console();?

try this code to check if your eclipse supports it... my eclipse doesn't support console also.

package console;


public class Console {

	public static void main(String[] args) { console = System.console();
		if (console == null) { System.out.println("unable to obtain console:(");
			String name = console.readLine();


otherwise use bufferedreader and inputstreamreader

BufferedReader keyboard;
keyboard = new BufferedReader(new InputStreamReader(;
String input = keyboard.readLine();

If it doesn't support something and you *must* do it that way, get another IDE temporarily or for good

Read the Javadocs for the Console class; it has the answer for your "why".

[...] Whether a virtual machine has a console is dependent upon the underlying platform and also upon the manner in which the virtual machine is invoked. If the virtual machine is started from an interactive command line without redirecting the standard input and output streams then its console will exist and will typically be connected to the keyboard and display from which the virtual machine was launched. If the virtual machine is started automatically, for example by a background job scheduler, then it will typically not have a console. [...]

I transfered everything on a notepad and i test my code from there..

it is two weird that eclipse, didnt put that function

I know this is marked "solved", but here's some more info that may be helpful.
1. The console problem is generic to IDE's. NetBeans has it as well. It's a Java thing, as ~s.o.s~ noted.
2. You can achieve the same result easily by using a BufferedReader on as follows:

try {
         BufferedReader reader = new BufferedReader(new InputStreamReader(;
         System.out.print("Type name: ");
         String name = reader.readLine();
         System.out.println("Hello " + name);
      } catch (IOException e) {

This works perfectly under the current Eclipse/Java versions on Win 7.