Saturday, September 19, 2009

You must use a Java 1.5 runtime to use GWT Hosted Mode on Mac OS X.

After the upgrade to Snow Leopard Mac OS X 10.6 I got the following error in GWT Eclipse console:

You must use a Java 1.5 runtime to use GWT Hosted Mode on Mac OS X.

I FIXED this issue by restoring Java 1.5 from my Time Machine in following steps:

1) Verify that Java 1.5.0 is missing from Snow Leopard
1.5.0 -> CurrentJDK
CurrentJDK -> 1.6

uki@Uki:/System/Library/Frameworks/JavaVM.framework/Versions $ ls -alt
total 48
drwxr-xr-x 11 root wheel 374 Sep 19 00:18 .
drwxr-xr-x 11 root wheel 374 Sep 19 00:18 ..
drwxr-xr-x 8 root wheel 272 Sep 19 00:17 A
lrwxr-xr-x 1 root wheel 1 Sep 19 00:17 Current -> A
lrwxr-xr-x 1 root wheel 5 Sep 19 00:17 1.6 -> 1.6.0
drwxr-xr-x 7 root wheel 238 Sep 19 00:17 1.6.0
lrwxr-xr-x 1 root wheel 3 Sep 19 00:17 CurrentJDK -> 1.6
lrwxr-xr-x 1 root wheel 5 Sep 19 00:17 1.3 -> 1.3.1
lrwxr-xr-x 1 root wheel 10 Sep 19 00:17 1.5 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Sep 19 00:17 1.5.0 -> CurrentJDK
drwxr-xr-x 3 root wheel 102 Jul 20 18:35 1.3.1
uki@Uki:/System/Library/Frameworks/JavaVM.framework/Versions $

2) Restore Java 1.5.0 from your Time Machine (if you have no backup, shame on you!)


3) Create a symbolic link (sudo ln -s 1.5.0/ CurrentJDK)


uki@Uki:/System/Library/Frameworks/JavaVM.framework/Versions $ sudo ln -s 1.5.0/ CurrentJDK

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
uki@Uki:/System/Library/Frameworks/JavaVM.framework/Versions $ ls -alt
total 40
drwxr-xr-x 11 root wheel 374 Sep 19 06:38 .
lrwxr-xr-x 1 root wheel 6 Sep 19 06:38 CurrentJDK -> 1.5.0/
drwxr-xr-x 11 root wheel 374 Sep 19 00:18 ..
drwxr-xr-x 8 root wheel 272 Sep 19 00:17 A
lrwxr-xr-x 1 root wheel 1 Sep 19 00:17 Current -> A
lrwxr-xr-x 1 root wheel 5 Sep 19 00:17 1.6 -> 1.6.0
drwxr-xr-x 7 root wheel 238 Sep 19 00:17 1.6.0
lrwxr-xr-x 1 root wheel 5 Sep 19 00:17 1.3 -> 1.3.1
lrwxr-xr-x 1 root wheel 10 Sep 19 00:17 1.5 -> CurrentJDK
drwxr-xr-x 3 root wheel 102 Jul 20 18:35 1.3.1
drwxr-xr-x 8 root wheel 272 May 7 2008 1.5.0
uki@Uki:/System/Library/Frameworks/JavaVM.framework/Versions $

4) Verify that you have the right set up

uki@Uki:/System/Library/Frameworks/JavaVM.framework/Versions $ java -version
java version "1.5.0_20"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_20-b02-315)
Java HotSpot(TM) Client VM (build 1.5.0_20-141, mixed mode, sharing)
uki@Uki:/System/Library/Frameworks/JavaVM.framework/Versions $

The GWT will work now, I will switch to Java 1.6 AFTER GWT release next update.