Results 1 to 9 of 9

Thread: Error message "Scanner cannot be resolved into a class" in Java.

Threaded View

  1. #1
    Join Date
    Feb 2014
    Beans
    4

    Error message "Scanner cannot be resolved into a class" in Java.

    Edit: oops meant to title "Scanner object cannot be resolved into a type"

    I am trying to use the Scanner object in Java for a homework assignment.
    Here's the program. It's written on notepad but compiled and run on a server belonging to the school.
    Code:
    import java.util.Scanner;
    class Palindrome
    {
    public static boolean isPalindrome(String s)
    {
        if (s.length() <= 1)
        {
            return true; //base case
        }
        else if(s.charAt(s.length()) == s.charAt(0))
        {
            isPalindrome(s.substring(1, s.length() - 1)); //passes a new substring excluding first and last character
        }
    }
    public static void main (String [] args)
    {
        System.out.println("Please input a string to see if it is a palindrome!");
        Scanner keyboard = new Scanner(System.in);
        String input = keyboard.nextLine();
        
        if (isPalindrome(input) == true)
        {
            System.out.println(input + " is a palindrome!");
        }
        else
        {
            System.out.println(input + " is not a palindrome!");
        }
    }
    }
    I was using Scanner without any problems last semester but upon compiling the program on the schools server I got this error.
    Here's what happens when I type the command "java -version"

    Code:
    java version "1.5.0"
    gij (GNU libgcj) version 4.2.4 (Ubuntu 4.2.4-1ubuntu3
    )

    And here's "javac -version"

    Code:
    gcj-4.2 (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu3)
    The javac command only showing some ubuntu info troubles me, but I don't understand how that could be a problem on my end, seeing as how the programs are compiled and run on a different machine. I messed around with Eclipse a while ago, did I screw something up with the version of the compiler? I don't see how that would affect anything outside of Eclipse though...
    Thanks for the help.
    Last edited by Harrison_Selle; February 11th, 2014 at 02:01 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •