Java Troubles :(

Discussion in 'Mac Programming' started by Maleficum, Nov 13, 2006.

  1. Maleficum macrumors member

    Joined:
    Jun 29, 2006
    Location:
    In a Chair
    #1
    Code:
    import static java.lang.System.*;
    import java.util.Scanner;
    

    This isn't all of my code. But, when I try to run that with the rest of the code (The code is a mandatory Scanner assignment), I get the following error:

    [​IMG]

    Can anyone help? It's getting annoying that I can't even run simple code...
     
  2. szark macrumors 68030

    szark

    Joined:
    May 14, 2002
    Location:
    Arid-Zone-A
  3. Maleficum thread starter macrumors member

    Joined:
    Jun 29, 2006
    Location:
    In a Chair
    #3
    When I do that, I get 15 errors, all saying something along the lines of

    symbol : class Scanner
    location: package util
    import java.util.Scanner;

    :(
     
  4. shambolic macrumors regular

    Joined:
    Oct 27, 2003
    Location:
    Staten Island, NY
    #4
    check java version - Scanner needs 1.5

    What version of java are you running?

    Open Terminal and type "java -version" to find out. The java.util.Scanner class requires 1.5 (or 5.0, depending how you count), whereas a standard Tiger install comes with 1.4.2 as the default, and 1.5 not installed. (It wasn't quite ready when Apple released Tiger)

    Assuming you're on Tiger, you can get Apple's implementation of 1.5 here.

    I believe - but am prepared to be corrected - that once you install this, it will change the default console version of java to 1.5 for you. If it doesn't, then the following terminal commands will do the trick:

    sudo rm /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

    sudo ln -s /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

    (yes, there's probably a way of updating the symlink rather than deleting/recreating it, but I've never bothered to learn it)
     

Share This Page