Hi Andrea,
i use the following to detect Java3D
try {
// initialize some J3D object (don't include any J3D object in the members of
the class implementing this
// otherwise the ClassLoader will throw this exception and you are not able to
catch it.
new javax.media.j3d.Canvas3D();
}
catch ( NoClassDefFoundError e ) { // jar files not there
hasJava3D = false;
}
catch ( UnsatisfiedLinkError e ) { // dll's not there
hasJava3D = false;
}
catch ( ExceptionInInitializerError e ) {
hasJava3D = false;
}
i think it's not recommended to simply catch all Errors!!!
to detect java versions (for distinguishing Java3D 1.2.x and 1.3x) i use the following
try {
getView().setTransparencySortingPolicy( View.TRANSPARENCY_SORT_GEOMETRY );
AppearanceHelper.setJava3DVersion( AppearanceHelper.JAVA3D_1_3 );
// version is 1.3x
}
catch( NoSuchMethodError e ) {
// version is 1.2x
}
you might also use reflection on the View class and detect the
setTransparencySortingPolicy in the list of the
classes methods. using refelection would also enable you to compile your code with
1.2.x Java3D releases which is not possible in the upper case
the code would look like:
java.lang.reflect.Method[] methods = javax.media.j3d.View.class.getMethods();
// can methods for a method named setTransparencySortingPolicy (which btw is a 1.3
method)
Hope this helps,
Karsten
Andrea Boright wrote:
> I am using Java3D (1.2.1_04) in an applet (NOT as an application!), and would like
>to detect the version of Java3D. (I'm also using Jdk1.4.0.) When I use the
>following code, p always returns null, even though I have installed Java3D, and my
>other 3D applets run fine.
>
> Package p = Package.getPackage( "javax.media.j3d" );
> String version = p.getImplementationVersion();
>
> I read a suggestion to look at the PackageInfo program in the demo examples, but it
>can only be run as an application.
>
> Is there anything else I can do?
>
> Thanks,
>
> Andrea Boright
>
> ===========================================================================
> 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".
===========================================================================
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".