I spent most of the weekend fighting this.  Eventually I'll get around to
writing a real HOWTO, but maybe this will help some other folks out.

1. It can be done.  I've run it under IE5 and Nav 4.61 on WinNT Workstation
and Win95.  For now, I'm specializing on IE because the *right* way to
do this is with the <OBJECT> tag and I refuse to use the egregious
netscape <APPLET>/<EMBED> botch.

2. Go get the instructions at Tornado Labs, specifically
http://www.tornadolabs.com/News/Java_3D_Installation/java_3d_installation.html
and follow them.  I have a feeling that maybe half the steps are not actually
necessary with recent J3Ds and JDKs, but I don't know which half.

3. The installs for JDK and J3D and JRE are all by default in
different (and I think arguably wrong) places.  I haven't figured out what
the *real* right place is - see below.

4. Installing the JRE installs the Java plug-in so you can run 1.2.
After this, your "start" menu will have a "Java Plugin Control Panel".
Pop this up and enable the plugin console.  You must do this because it
is 100% certain that your applet won't run at first, and if you really
know java and windows you can actually use the error messages to figure
out what's going on.  In particular, when it blows up, go hit the jdk1.2.2
javadocs on the actual exception that occurred - sometimes the name of
the exception doesn't tell you anything useful but there will be good
stuff in the javadoc.

5. If you're using the <OBJECT> tag to run the plugin, here's an example
of some working HTML code:

<OBJECT classid='clsid:8AD9C840-044E-11D1-B3E9-00805F499D93'
 width='547' height='453'
 
java_codebase='http://java.sun.com/products/plugin/1.2/jinstall-12-win32.cab#Version=1,2,0,0'
 style='position:absolute;top:50;left:91; height:453;width:547;'>
  <PARAM NAME='java_code' VALUE='Browser.class'>
  <PARAM NAME='archive' VALUE='Browser.jar'>
  <PARAM NAME='codebase' VALUE='/browser/'>
  <PARAM NAME='java_type' VALUE='application/x-java-applet;version=1.2'>
  <PARAM NAME='ash_path' VALUE='1.7.6.6.7.6.5.9.1.8'>
  <PARAM NAME='ash_x' VALUE='4695557'>
  <PARAM NAME='ash_z' VALUE='1411584'>
</OBJECT>

Of course a lot of this is specific to my app.  Once again, I'm not sure if
*all* of it is really necessary.  Observe that you have to give the codebase
and any applet parameters (in my case prefixed with "ash_") in <param>
elements; the codebase= attribute is ignored.

6. If you're like most J3D newbies, your mainline will be cut-n-pasted
from either the tutorial examples or the ones that come with j3d itself.
These all are of the form

 public class Foo extends Applet {
   public Foo {
     ... construct the scene graph ...
   }
   ...
   public static void main(String[] args) {
         Frame frame = new MainFrame(new Foo(), 256, 256);
   }
 }

This may work as an App, but it will *not* work as an applet.  No
init() or start() or stop() or applet machinery.  And furthermore the
typical constructor apparently does some no-nos because mine regularly
blew up with unhelpful messages.  Doh.  So since you probably want to
debug as an app and run as an applet, you'll end up with a fairly complex
mainline class that has an init() and start() and some state variables
saying whether it's in an applet and a main that calls the init() and
start() and so on.  In my case I ended up with no constructor at all,
using the default applet constructor.  It would be real nice if the j3d
group would publish a sample one of these that actually works.

I haven't doped out yet what you should do in the stop() & destroy()
applet methods; the winNT task manager seems to tell me that java goes
to sleep once the browser moves on on from the page with my applet, so for
now I'm not doing anything there.

7. Path and classpath will cause you problems.  There is no documentation
that says where the java plugin actually goes to look for classes; I seemed
to need to set the classpath on win95 but not winNT.  If you end up having
the .class files in c:\jdk1.2.2\...\lib and ...\lib\ext and
\Program Files\Javasoft\JRE\1.2\... \lib and ...\ext and maybe a couple
other places, eventually the plug-in will find it.

Similarly, the plug-in doesn't say where it actually goes looking for the
DLLs it runs that actually *implement* the J3D stuff.  Once again on NT,
the installation left it in a place where the plug-in found it, on win95
I ended up copying the DLLs to several \bin directories in parallel with
the \lib directories listed above and eventually it found them.

8. When your applet fails to run, go back to Tornado Labs and see if you
can run their Bench3d applet (pointed to from the page mentioned above) -
if it doesn't work, the error messages in the java plugin console will
probably help you figure out why not.

9. Immense thanks are due to Mitch Williams and Dan Selman, who helped
me bash through some of these steps.

10. It would be good if the java3d team were to take ownership of this
problem and get it in the FAQ, and maybe even arrange that for future
releases, if you just install various combinations of jdk/jre/j3d and take
all the defaults, you get something that works.

Cheers, Tim

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to