Pregunta

I made Desktop app with netbeans platform in java.In my app i using JAI and Java3d. This app i made for dentist. So every installation time doctore do not want to inastall jai, java3D, its like headache for dentist. So i have to check at starting of my app that if JAI and Java3D is installed or not? if not then install JAI and Java3D programetically from my app. So how can i do that?

¿Fue útil?

Solución

public class ClassUtils {
  public static boolean isAvailable(String className) {
    boolean isFound = false;
    try {
       Class.forName(className, false, null);
       isFound = true;
    }
    catch (ClassNotFoundException e) {
       isFound = false;
    }
    return isFound;
  }

  public static boolean isJava3dAvailable() {
   return isAvailable("javax.media.j3d.View");
  }

  public static void  main(String args[]) {
    System.out.println ("JAI " +
       (ClassUtils.isAvailable("javax.media.jai.ImageJAI")?"present":"missing"));
    System.out.println ("Java3d " +
       (ClassUtils.isJava3dAvailable()?"present":"missing"));
  }

}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top