tags:

views:

269

answers:

2

My 10.5.3 install on a MacBook doesn't seem to want to build an example from Sun. It claims it can't find java.io.Console to import. This is annoying to me, and after much searching I can't figure out what I should do to fix it.

I have installed the Apple Developer Tools.

Here's what happens:

macbook:~ dlamblin$ javac RegexTestHarness.java
RegexTestHarness.java:32: cannot find symbol
symbol  : class Console
location: package java.io
import java.io.Console;
               ^
RegexTestHarness.java:39: cannot find symbol
symbol  : class Console
location: class RegexTestHarness
        Console console = System.console();
        ^
RegexTestHarness.java:39: cannot find symbol
symbol  : method console()
location: class java.lang.System
        Console console = System.console();
                                ^
3 errors
+5  A: 

mmyers already hinted at this, but it sounds like you've not upgraded to Java 6. You can get it from here: http://support.apple.com/downloads/Java_for_Mac_OS_X_10_5_Update_4

John Munsch
Thanks; I did need to do this AND drag it to the top of the list in the "Java Preferences" app.
dlamblin
+3  A: 

I assume you have already installed Java 6 on your machine, because java.io.Console is a Java 1.6 class. I have run into cases where I update OS X to Java 6, but when run from a command line, the older version is still used. This has happened even after adjusting the Java Preferences app (Applications > Utilities > Java Preferences).

Here is how I worked around it.

$ cd /System/Library/Frameworks/JavaVM.framework/Versions
$ sudo rm CurrentJDK
$ sudo ln -s 1.6.0 CurrentJDK
William Brendel