Results 1 to 3 of 3
  1. #1
    stevenhaynes5 is offline Member
    Join Date
    May 2011
    Posts
    17
    Rep Power
    0

    Default Error compling my java program on unix

    Hi,

    Im trying to comple my java program but i get a few errors:

    Java Code:
    user> javac help.java
    help.java:5: cannot resolve symbol
    symbol  : class Scanner
    location: package util
    import java.util.Scanner;
                     ^
    help.java:22: cannot resolve symbol
    symbol  : class Scanner
    location: class help
                Scanner file = new Scanner(new File("help_file"));
                ^
    help.java:22: cannot resolve symbol
    symbol  : class Scanner
    location: class help
                Scanner file = new Scanner(new File("help_file"));
                                   ^
    3 errors
    Here is the program.

    Java Code:
    /**
     *
     * @author steven.haynes
     */
    import java.util.Scanner;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    
    public class help {
        
        public static void main(String[] args) {
            
            String line = null;
            String input = null;
            String exit = null;
            
            input = args[0];
            exit = "END";
            
            try {
                Scanner file = new Scanner(new File("help_file"));
                
                while (file.hasNext()) {
                
                    line = file.nextLine();
                    
                    line = line.trim();
                
                    if (line.equals(input)) {
                    
                        do {
                            line = file.nextLine();
                            System.out.println(line);
                        } while (!line.equals(exit));
                    }
                }
                
                file.close();
                
            } 
            
            catch (FileNotFoundException e) {
                e.printStackTrace();
            } 
            
            catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
    Thanks,

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default

    What version of Java are you compiling with?
    (java -version)
    ETA: actually javac -version...

  3. #3
    stevenhaynes5 is offline Member
    Join Date
    May 2011
    Posts
    17
    Rep Power
    0

    Default

    Version 1.4. I have discovered Scanner is only supported on 1.5 onwards.

    Thanks for your help

Similar Threads

  1. Replies: 0
    Last Post: 04-28-2010, 12:32 PM
  2. set environment variable in unix using java program
    By java_kick in forum Advanced Java
    Replies: 3
    Last Post: 03-16-2009, 12:26 PM
  3. can java program display icon on unix?
    By java2008 in forum Advanced Java
    Replies: 1
    Last Post: 10-06-2008, 07:33 AM
  4. JAVA compilation error in UNIX
    By satish kumar in forum Advanced Java
    Replies: 9
    Last Post: 08-08-2008, 07:36 AM
  5. Running java program with arguments in Unix"
    By gvi in forum Advanced Java
    Replies: 2
    Last Post: 11-08-2007, 07:01 PM

Posting Permissions

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