throw new NoAvailableBackendException( "Please ensure that you have an nd4j backend on your classpath. Please see: http://nd4j.org/getstarted.html");
throw new NoAvailableBackendException( "Please ensure that you have an nd4j backend on your classpath. Please see: http://nd4j.org/getstarted.html");
/** * Adds the supplied Java Archive library to java.class.path. This is benign * if the library is already loaded. * @param jar the jar file to add * @throws NoAvailableBackendException */ public static synchronized void loadLibrary(File jar) throws NoAvailableBackendException { try { /*We are using reflection here to circumvent encapsulation; addURL is not public*/ java.net.URLClassLoader loader = (java.net.URLClassLoader) ClassLoader.getSystemClassLoader(); java.net.URL url = jar.toURI().toURL(); /*Disallow if already loaded*/ for (java.net.URL it : java.util.Arrays.asList(loader.getURLs())) { if (it.equals(url)) { return; } } java.lang.reflect.Method method = java.net.URLClassLoader.class.getDeclaredMethod("addURL", new Class[] {java.net.URL.class}); method.setAccessible(true); /*promote the method to public access*/ method.invoke(loader, new Object[] {url}); } catch (final java.lang.NoSuchMethodException | java.lang.IllegalAccessException | java.net.MalformedURLException | java.lang.reflect.InvocationTargetException e) { throw new NoAvailableBackendException(e); } }
/** * Adds the supplied Java Archive library to java.class.path. This is benign * if the library is already loaded. * @param jar the jar file to add * @throws NoAvailableBackendException */ public static synchronized void loadLibrary(File jar) throws NoAvailableBackendException { try { /*We are using reflection here to circumvent encapsulation; addURL is not public*/ java.net.URLClassLoader loader = (java.net.URLClassLoader) ClassLoader.getSystemClassLoader(); java.net.URL url = jar.toURI().toURL(); /*Disallow if already loaded*/ for (java.net.URL it : java.util.Arrays.asList(loader.getURLs())) { if (it.equals(url)) { return; } } java.lang.reflect.Method method = java.net.URLClassLoader.class.getDeclaredMethod("addURL", new Class[] {java.net.URL.class}); method.setAccessible(true); /*promote the method to public access*/ method.invoke(loader, new Object[] {url}); } catch (final java.lang.NoSuchMethodException | java.lang.IllegalAccessException | java.net.MalformedURLException | java.lang.reflect.InvocationTargetException e) { throw new NoAvailableBackendException(e); } }