When I did so yesterday (on a Linux 9.1 machine, using the NetBeans 4.0 platform and building project with java platform set to both 1.5.0 (system default - first try) and 1.4.2 (browser plugin setting - second try)) I kept getting above-mentioned error message.
Further on, I tried using a JApplet (first effort), then humbly switching to good old java.applet.Applet(second effort). Same thing happening all the time.
Message in browser window keeps nagging about "Applet being notinited" though I definitely did so (doing some basic initialization such as setting size to 800 by 600 and setting background color).
I recently switched java version settings to 1.5.0 (which is another interesting story on a linux machine). I just don't seem to get why Applet won't work with either system default or browser java-version setting.
Java Applications work perfectly fine on my System and, switching to 1.4.2 platform, on other machines as well so this seems to be an applet-related problem (maybe including peculiarities of linux vm, who knows?).
Any ideas, anyone?
Thanks in advance for any suggestions to this presumably pretty stupid question ...
[ July 16, 2005: Message edited by: Steffen Reinhard ] [ July 16, 2005: Message edited by: Steffen Reinhard ]
The "not inited" message doesn't mean you didn't write init() -- it means there was a exception while initializing or creating the applet. You know what that exception is: it's the "unsupported major.minor version" error.
This message means that a 1.4 (or earlier) VM is trying to read class files compiled for 1.5 (verison 49.0). You can either:
1) Search your machine and make absolutely sure you've deleted all the .class files you've compiled for your applet, then compile with 1.4, or
2) Again, carefully delete all the class files, then compile with 1.5, but use this switch: "-source 1.4" to tell the compiler to emit class file compatible with Java 1.4 as well as 1.5 .
Thanks a lot for your immediate reply. I really do appreciate being here!
Just to make sure I got your answer correctly ... Installing browser plugin version 1.5.0 would make the damn applet run correctly on my machine.
On the other hand, compiling the whole thing with a version 1.4.x compiler would make it run on other people's machines as well (provided they have a version 1.4.something browser plugin installed on their machine) whereas compiling the applet with a version 1.5.0 compiler would do the trick for both 1.4.x and 1.5.x browser plugin versions?
Other way around. Class files are forward compatible with future runtimes, but not necessarily backward-compatible with old runtimes. So a 1.5 compiler will (without using that -source 1.4 switch) compile classes that will work with 1.5 only. Compiling with 1.4, or equivalently using 1.5 with the -source 1.4 switch, will build classes that work with 1.4 or 1.5.
Switching to java SDK 1.4.2 really did it. As far as I could ascertain current java plugin version in most browsers seems to be 1.4.something. As my IDE can handle different java versions on the project level, I tried using a 1.5 environment using the -source:1.4 switch which succeeded in running the applet on my office machine (Windows box).
Exporting the project to my usb stick and importing it into the IDE on my machine at home (this one also running on 1.5.0 and Linux) didn't work out as expected, even using the -source:1.4 switch. Hmm. Strange but true. Maybe the "clean and build" option doesn't really clean up that well as I always thought it would ...
Finally, switching the preset java version from 1.5.0 to 1.4.2 in the ide on both my home machine and my office machine (as well as on my notebook in both Linux and Windows versions of my favorite IDE) did the trick.
I'd like to state once more how much I do appreciate your immediate response. Thanks a lot!