random technical thoughts from the Nominet technical team

Restarting the AWT Native Event Thread

1 Star2 Stars3 Stars4 Stars5 Stars (12 votes, average: 4.92 out of 5)
Loading ... Loading ...
Posted by simon on Apr 24th, 2008

I recently upgraded my OS X Java development environment to
the Java SE 6 Developer Preview 9 release. After the upgrade I encountered the following error when running code which relied upon the AWT libraries:

seventh-circle$ java AWTExample
2008-04-24 12:15:12.061 java[1035:10b] Apple AWT Startup Exception : *** -[NSCFArray insertObject:atIndex:]: attempt to insert nil
2008-04-24 12:15:12.087 java[1035:10b] Apple AWT Restarting Native Event Thread

Ugoogalizing the stack trace indicated this was a rare but not unknown problem, with no obvious solution. A known unknown, if you will.

After blaming everyone else I retraced my steps and realised that I had changed the CurrentJDK and Current symlinks in /System/Library/Frameworks/JavaVM.framework/Versions to point at 1.6, in a misguided attempt to make this the default version of Java for the shell. Specifically by repointing the Current symlink from A to 1.6 I had broken the Java Native Foundation framework. I reset the symlink and chalked the lost hours up to the arrogance of youth:

cd /System/Library/Frameworks/JavaVM.framework/Versions
sudo rm Current
sudo ln -s A Current

In summary, if you want to change the default version of Java to 1.6 for a command line process on OS X, I’d recommend using the Java Preferences Application. If you want to be sure add the following to your .bash_profile:

JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH

21 Responses

  1. Ak Says:

    Very useful, thank you !

  2. Dan Fabulich Says:

    Fixed my problem, too, this time on the official released version of Java 6 that comes with Leopard 10.5.3. I was puzzled to find that Java 1.5 remained the default after installing Java 1.6; I too carelessly rerouted my framework symlinks. Restoring the framework symlinks to their normal state, running Java Preferences, and configuring my PATH fixed the problem for me.

  3. Tim Says:

    Just to say thanks. I had done exactly the same thing, and was probably even scratching the same part of my head.

    What I hadn’t managed however was to find the solution, but you had, so thankyou very much indeed.

  4. matt Says:

    I’m seeing this error, but this fix didn’t work for me.

    still searching for clues…

  5. Simon Says:

    Hi Matt,

    What do you get if you run the following from the command line:

    ls -l /System/Library/Frameworks/JavaVM.framework/Versions

  6. When Java Apps don’t start in OS X… | Wulf Says:

    […] http://blog.nominet.org.uk/tech/2008/04/24/restarting-the-awt-native-event-thread/  […]

  7. Marc A. Meyer Says:

    wow, thanks. i tried everything to get my intellij to start again. A lifesaver!

  8. Gubatron Says:

    Thanks for this Lifesaver.

  9. jason Says:

    yay! thanks for the tip, that’s an hour of my life I’ll never get back, but thanks to you it wasn’t more than that!

  10. marlacorinne.4parkers.com » Upgrading to Java SE 6 Says:

    […] online.  He had never seen this error before, checked a few things, then he googled and found this wonderful post, correctly identified in the comments as a […]

  11. Lionel Says:

    This was a great help, since I had originally changed the symbolic links as result of a web posting.

  12. tamara Says:

    Thanks, finally solved my issue. I had been messing around with the symbolic link due to other web posts and it just made things worse.

  13. Michael BL Says:

    Whew thanks! Saved me from what would have been an hour or two of mucking around.

  14. Andrew C Says:

    Java Prefences never has done anything at all on my mac. I have no choice but to move the symlinks. I cannot get around the AWT problem AND use java 1.6. This is the output of my ln -ls …/Versions:

    lrwxr-xr-x 1 root wheel 1 Jun 22 19:55 Current -> A
    lrwxr-xr-x 1 root wheel 3 Jun 22 19:38 CurrentJDK -> 1.6

  15. P4n1kH0u53 Says:

    I also changed my symlinks trying to get my command line compile to work. Changing the symlinks did indeed give me the AWT error. I reset the defaults in the Java Preferences app and manually restored the symlinks. Now my application launches, but it doesn’t build without the manual edit of the links. What in the world?

    sh-3.2# ls -l /System/Library/Frameworks/JavaVM.framework/Versions
    total 64
    lrwxr-xr-x 1 root wheel 5 Jun 18 11:02 1.3 -> 1.3.1
    drwxr-xr-x 3 root wheel 102 Dec 2 2007 1.3.1
    lrwxr-xr-x 1 root wheel 5 Jun 18 11:02 1.4 -> 1.4.2
    lrwxr-xr-x 1 root wheel 3 Jul 22 2008 1.4.1 -> 1.4
    drwxr-xr-x 8 root wheel 272 Jul 22 2008 1.4.2
    lrwxr-xr-x 1 root wheel 5 Jun 18 11:02 1.5 -> 1.5.0
    drwxr-xr-x 9 root wheel 306 Jun 11 14:10 1.5.0
    lrwxr-xr-x 1 root wheel 5 Jun 18 11:02 1.6 -> 1.6.0
    drwxr-xr-x 9 root wheel 306 Jul 10 10:43 1.6.0
    drwxr-xr-x 9 root wheel 306 Jul 10 10:49 A
    lrwxr-xr-x 1 root wheel 1 Jul 10 11:10 Current -> A
    lrwxr-xr-x 1 root wheel 3 Jul 10 11:10 CurrentJDK -> 1.5

  16. Simon Says:

    Hi there,

    Try manually setting your JAVA_HOME and PATH environment variables in your shell. I have outlined the steps at the end of the post. This has fixed the problem for other people.

  17. Fraer9 Says:

    Excellent ! Thanks for this !

  18. Jpenguin zhenlei Says:

    Wow. Thanks! saved my butt when my GWT compile wouldn’t work.

  19. Vince Says:

    Thanks so much! I had the exact same problem and I had done the exact same re-linking to 1.6, just before. So.. thanks again and thanks internet.

  20. Georges Says:

    I’ve done what you outlined above, but when I launch Java preferences or any java for that matter I still get the error:
    ZoneInfo: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/zi/ZoneInfoMappings (No such file or directory)

    here’s a ls -l on the java framework directory:

    total 56
    lrwxr-xr-x 1 root wheel 5 3 Sep 23:39 1.3 -> 1.3.1
    drwxr-xr-x 3 root wheel 102 18 Jul 2008 1.3.1
    lrwxr-xr-x 1 root wheel 5 3 Sep 23:39 1.4 -> 1.4.2
    lrwxr-xr-x 1 root wheel 3 4 Nov 2008 1.4.1 -> 1.4
    drwxr-xr-x 8 root wheel 272 4 Nov 2008 1.4.2
    lrwxr-xr-x 1 root wheel 5 3 Sep 23:39 1.5 -> 1.5.0
    drwxr-xr-x 9 root wheel 306 25 Oct 19:00 1.5.0
    lrwxr-xr-x 1 root wheel 5 25 Oct 21:00 1.6 -> 1.6.0
    drwxr-xr-x 8 root wheel 272 5 Nov 2008 1.6.0
    drwxr-xr-x 8 root wheel 272 3 Sep 23:39 A
    lrwxr-xr-x 1 root wheel 1 25 Oct 18:46 Current -> A
    lrwxr-xr-x 1 root wheel 3 25 Oct 19:01 CurrentJDK -> 1.5

    any idea?
    I could have messed with other symlinks, but the /usr/bin/java one is good, any idea what else I should check?

  21. S. Ali Tokmen Says:

    Hello

    Excellent tip! This has also solved the issue where the “Java Preferences” utility didn’t open anymore.

    Cheers

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Recent Posts

Highest Rated

Categories

Archives

Meta: