View Javadoc

1   package nl.tudelft.goal.unreal.util.vecmathcheck;
2   
3   import java.net.URL;
4   
5   import javax.vecmath.Matrix3d;
6   
7   /**
8    * Utility class to check if the correct version of Vecmath is loaded. This is
9    * needed because OSX installs Java3D as a Java extension. This extension uses
10   * version 1.3 of Vecmath.jar. Other projects use version 1.5.* Because java
11   * extensions are always loaded before our own libraries we end up with the
12   * wrong version loaded.
13   * 
14   * @author mpkorstanje
15   * 
16   */
17  public class VecmathCheck {
18  
19  	public static final String minimumVersion = "1.5";
20  
21  	public static boolean check() {
22  		
23  		if(getSpecificationVersion() == null){
24  			//
25  			return true;
26  		}
27  		
28  		return Matrix3d.class.getPackage().isCompatibleWith(minimumVersion);
29  	}
30  
31  	public static String getMinimumVersion() {
32  		return minimumVersion;
33  	}
34  
35  	public static String getSpecificationVersion() {
36  		return Matrix3d.class.getPackage().getSpecificationVersion();
37  	}
38  
39  	public static URL getPackageDir() {
40  		return Matrix3d.class.getProtectionDomain().getCodeSource().getLocation();
41  	}
42  
43  	public static String getErrorMessage() {
44  		return "Version " + VecmathCheck.getMinimumVersion() + " of Vecmath.jar is required. "
45  				+ "You have version " + VecmathCheck.getSpecificationVersion() + " on your class path at:\n" 
46  				+ VecmathCheck.getPackageDir() +".\n"
47  				+ "Please remove this version from the class path.";
48  	}
49  }