Search code examples
javaeclipsemacosdependenciesjava-3d

Overriding Java System Library with newer class on Mac


I'm trying to compile and run a Java3D project on my mac and having some trouble. I'm using Eclipse. The program depends on an old version of Java3D, but even after I add the correct Jars in Eclipse it still is looking in the default system location instead.

When running my program in Eclipse, I get this issue:

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: javax.media.j3d.BranchGroup.pickAllSorted(IILjavax/media/j3d/PickShape;)[Ljavax/media/j3d/PickInfo; at com.sun.j3d.utils.pickfast.PickTool.pickAllSorted(PickTool.java:410)

BranchGroup.pickAllSorted does not exist in the Mac Default JRE System Library (JVM 1.6.0), but it does exist in the correct JAVA3D jars that I have included. I've added them to my buildpath, AND they are referenced above the JRE system library in Properties-Java Build Path-Order and Export. This seems like it should be the solution but it doesn't work.

I've been trying for a while and cannot get it to work. One possible lead I had was to try putting the .jars in /Library/Java/Extensions. When I do this, I instead get an OpenGL error and my program doesn't open at all, but its doing something I guess.

Thanks for the help.


Solution

  • In Eclipse, go to Run > Run Configurations > Your Main > Arguments > VM Arguments and add -Xbootclasspath/p:newjava3d.jar. This prepends newjava3d.jar to your bootclasspath, so the relevant classes will be loaded from it.