This is just a really quick post to hopefully help anyone out that may be running into the same annoying problem I was with Flash CS4 and ActionScript 3 on Apple OS X (specifically 10.5).
I kept receiving the error pictured above, “Error initializing Java Runtime Environment. You may need to reinstall Flash,” whenever I would try to open a new ActionScript 3 project/file, or whenever I would try to run any AS3 code. The error didn’t occur when I was running ActionScript 2.0 projects.
After doing some searching on Google, and finding mostly solutions that were regarding the ‘CLASSPATH’ variable on Windows systems, it dawned on me that when I installed NetBeans IDE a few weeks back, it also installed a newer version of the Java Runtime Environment.
So I opened ‘Java Preferences.app’ which is installed in my ‘/Applications/Utilities/’ folder and found what I had suspected. My JRE was set to ‘Java SE 6.’
Apparently, Flash for some reason needs to run a 32-bit instance of JRE 5 on my machine when running ActionScript 3 code. This may be due to the fact I am running an older Intel Macbook Pro, or maybe Flash CS4 just needs an older version of Java. I honestly have no idea. But, after changing the Java Preferences to ‘J2SE 5.0 32-bit,’ Flash CS4 now runs without a hitch, and has no problem executing ActionScript 3. I do have to switch the preferences back to 6 when I run NetBeans, but that is fairly trivial using the Java Preferences panel.
If you don’t have ‘Java Preferences.app’ installed for some reason, you could try changing the preferred version manually from the command line by creating a symlink from ‘CurrentJDK’ to J2SE 5.0. However, I don’t recommend this route unless you know what you are doing.
Now, as I stated before, there are apparently several other issues that will also throw this same error (it’s pretty generic and unhelpful). This post isn’t intended to solve them all, but this is what worked for me. I hope it helps someone else and saves you a bit of a headache.