Unrecognized constructor for SQLException with the new Java 6 compiler

Discussion in 'Mac Programming' started by Lyle, Apr 30, 2008.

  1. Lyle macrumors 68000

    Lyle

    Joined:
    Jun 11, 2003
    Location:
    Madison, Alabama
    #1
    I've just downloaded the new Java SE 6 package and was going through the process of rebuilding various libraries and applications to see if anything broke. Looks like something did:

    Code:
    import java.sql.SQLException;
    
    try {
        ...
    } catch (SQLException ex) {
        throw new SQLException("message", ex);
    }
    This is (an abbrieviated form of) code which compiled fine under Java 5. The compiler is complaining that there's no such constructor for SQLException:

    Code:
    [javac] filename.java: cannot find symbol
    [javac] symbol  : constructor SQLException(java.lang.String,java.sql.SQLException)
    [javac] location: class java.sql.SQLException
    [javac]             throw new SQLException("Unable to retrieve dates", e);
    Is this a known problem?
     
  2. Lyle thread starter macrumors 68000

    Lyle

    Joined:
    Jun 11, 2003
    Location:
    Madison, Alabama
    #2
    OK, so it appears to be a problem with Ant and not with Java per se. That is, Ant is still looking at my Java 1.5 installation even though the links have been updated to point to Java 1.6. More on this story as it develops.
     
  3. RaceTripper macrumors 68030

    Joined:
    May 29, 2007
    #3
    Ant expects you to have a JAVA_HOME environment variable. Maybe you need to change that to point to the right JDK.
     
  4. Lyle thread starter macrumors 68000

    Lyle

    Joined:
    Jun 11, 2003
    Location:
    Madison, Alabama
    #4
    Yep, that was it. Well, actually, JAVA_HOME was defined:
    Code:
    export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
    but the problem is that when you install Java SE 6, even if you use the "Java Preferences" utility to change which runtime you want to use, it doesn't update the link for the "CurrentJDK" to point to the 1.6 JDK, and that's what was breaking things. To work around it, I just did this:
    Code:
    cd /System/Library/Frameworks/JavaVM.framework/Versions
    sudo rm CurrentJDK
    sudo ln -s 1.6 CurrentJDK
    
    Now my code compiles without errors.
     
  5. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #5
    The Java Preferences is for Applet and Application runtime selection.

    The new update won't change the default command line version of java as you found out. This is also mentioned in the Release Notes

    What really stinks is I can't install this update - now its officially time for a new MBP.
     
  6. m3the01 macrumors member

    Joined:
    Jun 18, 2007
    #6
    Anyway to get jdk 1.6 to show up in xcode?

    I tried the link command, but no luck.

    Thanks
     
  7. m3the01 macrumors member

    Joined:
    Jun 18, 2007
    #7
    I can compile and run everything using 1.6 however i cant get it to show up in xcode as a compile option.

    Ive reverted to commenting out the 1.6 code in xcode and for production testing i add it back in and manually compile through the terminal using
    /System/Library/Frameworks/JavaVM.framework/Versions/CurrenDK/Home/bin/javac

    and run it with,
    /System/Library/Frameworks/JavaVM.framework/Versions/CurrenDK/Home/bin/java


    Work great,

    If anyone knows a simple way to update the compiler in xcode to include the 1.6 javac lmk.

    Thanks!
     

Share This Page