Start New Discussion within our Software Development Community

when i run my project in java. i keep getting this stuff.
No Console ..... I dont know how to get console in eclipse.
here is my code.

import java.io.*;


public class WordGame {
	
	public WordGame()
	{
		
	}
	
	public static void main (String args[])
	{
		String WordGuess;
		
		 WordJudge gm = new WordJudge();
		gm.pickword();
		
	
		Console c = System.console();
		
		
		if (c == null){
			
			System.err.println("No Console.");
			System.exit(1);
			
		}
		
		while (!gm.gameEnded()){
			
			gm.displayWord();
			System.out.format("You have %d attempts remaining. \n", gm.getRemainingGuesses());
			strGuess = c.readLine("Enter your guess : ");
			gm.judgeGuess(WordGuess);
		
		}
		
		if (gm.plyrwin()){
			System.out.format("You won ! It took you %d attempts. \n", gm.nGuessesNeeded());
			System.out.format(gm.GetTheWord());
			
		}
		
		else{
			System.out.format("You lost. The word was %s \n", gm.GetTheWord());
			
		}
		
		
	}
	
	}

please help me ... badly needed your reply ASAP. Tnx in advance guys.

Eclipse has its own environment, and you can't get at the ordinary console.
You can get the same capabilities using a BufferedReader with System.in

import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;

...

          try {
             BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
             System.out.print("Type name: ");
             String name = reader.readLine();
             System.out.println("Hello " + name);
          } catch (IOException e) {
             e.printStackTrace();
          }
This question has already been answered. Start a new discussion instead.