Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Maleficum

macrumors member
Original poster
Jun 29, 2006
31
0
In a Chair
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:

Picture1-1.png


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

shambolic

macrumors regular
Oct 27, 2003
126
5
Staten Island, NY
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)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.