Restarting the AWT Native Event Thread
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

(13 votes, average: 4.92 out of 5)
May 16th, 2008 at 2:47 pm
Very useful, thank you !
July 2nd, 2008 at 9:03 pm
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.
August 2nd, 2008 at 5:26 pm
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.
October 15th, 2008 at 3:05 pm
I’m seeing this error, but this fix didn’t work for me.
still searching for clues…
October 16th, 2008 at 8:31 am
Hi Matt,
What do you get if you run the following from the command line:
ls -l /System/Library/Frameworks/JavaVM.framework/Versions
October 23rd, 2008 at 11:46 pm
[…] http://blog.nominet.org.uk/tech/2008/04/24/restarting-the-awt-native-event-thread/ […]
December 19th, 2008 at 7:47 am
wow, thanks. i tried everything to get my intellij to start again. A lifesaver!
January 16th, 2009 at 7:43 am
Thanks for this Lifesaver.
February 27th, 2009 at 4:48 pm
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!
March 25th, 2009 at 11:35 pm
[…] 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 […]
May 28th, 2009 at 10:26 pm
This was a great help, since I had originally changed the symbolic links as result of a web posting.
June 4th, 2009 at 11:26 pm
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.
June 9th, 2009 at 1:52 am
Whew thanks! Saved me from what would have been an hour or two of mucking around.
June 22nd, 2009 at 11:58 pm
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
July 10th, 2009 at 4:22 pm
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
July 14th, 2009 at 11:33 am
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.
August 25th, 2009 at 1:14 pm
Excellent ! Thanks for this !
September 9th, 2009 at 1:11 am
Wow. Thanks! saved my butt when my GWT compile wouldn’t work.
September 12th, 2009 at 8:20 pm
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.
October 25th, 2009 at 9:14 pm
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?
March 7th, 2010 at 1:56 pm
Hello
Excellent tip! This has also solved the issue where the “Java Preferences” utility didn’t open anymore.
Cheers
July 21st, 2010 at 3:23 pm
Although the post is a little older already, THANK YOU very much.
This Java setup is so horrible on OS X…