Example usage for java.lang ClassNotFoundException printStackTrace

List of usage examples for java.lang ClassNotFoundException printStackTrace

Introduction

In this page you can find the example usage for java.lang ClassNotFoundException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:LookAndFeelDemo.java

private static void initLookAndFeel() {
    String lookAndFeel = null;//w w  w.  ja  va2 s  . co m

    if (LOOKANDFEEL != null) {
        if (LOOKANDFEEL.equals("Metal")) {
            lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
            // an alternative way to set the Metal L&F is to replace the
            // previous line with:
            // lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel";

        }

        else if (LOOKANDFEEL.equals("System")) {
            lookAndFeel = UIManager.getSystemLookAndFeelClassName();
        }

        else if (LOOKANDFEEL.equals("Motif")) {
            lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
        }

        else if (LOOKANDFEEL.equals("GTK")) {
            lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
        }

        else {
            System.err.println("Unexpected value of LOOKANDFEEL specified: " + LOOKANDFEEL);
            lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
        }

        try {

            UIManager.setLookAndFeel(lookAndFeel);

            // If L&F = "Metal", set the theme

            if (LOOKANDFEEL.equals("Metal")) {
                if (THEME.equals("DefaultMetal"))
                    MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
                else if (THEME.equals("Ocean"))
                    MetalLookAndFeel.setCurrentTheme(new OceanTheme());
                else
                    MetalLookAndFeel.setCurrentTheme(new TestTheme());

                UIManager.setLookAndFeel(new MetalLookAndFeel());
            }

        }

        catch (ClassNotFoundException e) {
            System.err.println("Couldn't find class for specified look and feel:" + lookAndFeel);
            System.err.println("Did you include the L&F library in the class path?");
            System.err.println("Using the default look and feel.");
        }

        catch (UnsupportedLookAndFeelException e) {
            System.err.println("Can't use the specified look and feel (" + lookAndFeel + ") on this platform.");
            System.err.println("Using the default look and feel.");
        }

        catch (Exception e) {
            System.err.println("Couldn't get specified look and feel (" + lookAndFeel + "), for some reason.");
            System.err.println("Using the default look and feel.");
            e.printStackTrace();
        }
    }
}

From source file:cl.almejo.vsim.Main.java

private void setNativeLookAndFeel() {
    try {//w  ww .  j a v a2 s.  c o m
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        GTKHelper.installGtkPopupBugWorkaround();
    } catch (UnsupportedLookAndFeelException ex) {
        ex.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:cl.almejo.vsim.Main.java

private void setNimbusLookAndFeel() {
    for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            try {
                UIManager.setLookAndFeel(info.getClassName());
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();/*from   w ww .ja  v  a 2s. c o  m*/
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (UnsupportedLookAndFeelException e) {
                e.printStackTrace();
            }
            break;
        }
    }
}

From source file:org.web4thejob.util.converter.StringToClassConverter.java

@Override
public Class<?> convert(String source) {
    try {/*from   w  w  w.j a v a  2  s. com*/
        if (StringUtils.hasText(source)) {
            return Class.forName(source);
        }
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.cloudera.recordbreaker.hive.SequenceFileSerDe.java

void initDeserializer(String valClassNamePayload) {
    // none necessary
    AvroDatumConverterFactory adcFactory = new AvroDatumConverterFactory(new Configuration());
    try {/*from  w  w  w  . ja va2  s .c o m*/
        this.valADC = adcFactory.create(Class.forName(valClassNamePayload));
    } catch (ClassNotFoundException cnfe) {
        cnfe.printStackTrace();
    }
}

From source file:org.apache.tomcat.util.IntrospectionUtils.java

/**
 * Construct a URLClassLoader. Will compile and work in JDK1.1 too.
 *///from   ww  w .j  a va  2s  .  co m
public static ClassLoader getURLClassLoader(URL urls[], ClassLoader parent) {
    try {
        Class urlCL = Class.forName("java.net.URLClassLoader");
        Class paramT[] = new Class[2];
        paramT[0] = urls.getClass();
        paramT[1] = ClassLoader.class;
        Method m = findMethod(urlCL, "newInstance", paramT);
        if (m == null)
            return null;

        ClassLoader cl = (ClassLoader) m.invoke(urlCL, new Object[] { urls, parent });
        return cl;
    } catch (ClassNotFoundException ex) {
        // jdk1.1
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
}

From source file:org.jacpfx.spring.processor.StatelessScopedPostProcessor.java

@Override
public void postProcessBeanFactory(final ConfigurableListableBeanFactory factory) throws BeansException {
    final String[] stateless = factory.getBeanNamesForType(CallbackComponent.class);
    for (final String beanName : stateless) {
        final BeanDefinition beanDefinition = factory.getBeanDefinition(beanName);
        final String className = beanDefinition.getBeanClassName();
        try {//from w w  w  .  j a  v a 2  s  .  c o m
            Class<?> clazz = Class.forName(className);
            if (clazz.isAnnotationPresent(Stateless.class))
                beanDefinition.setScope("prototype");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }
}

From source file:org.workin.http.httpclient.v4.handler.response.JacksonResponseHandler.java

public void setBeanClass(String beanClass) {
    if (StringUtils.isNotBlank(beanClass)) {
        this.beanClass = beanClass.trim();
        try {//from   w  w  w.  j  ava  2  s.  com
            this.beanType = Class.forName(beanClass);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.apache.cordova.test.ActivityPlugin.java

public void startActivity(String className, String startUrl, JSONObject extraPrefs) throws JSONException {
    try {/*from  w ww.ja va2s.com*/
        if (!startUrl.contains(":")) {
            startUrl = "file:///android_asset/www/" + startUrl;
        }
        Intent intent = new Intent(this.cordova.getActivity(), Class.forName(className));
        intent.putExtra("testStartUrl", startUrl);
        Iterator<String> iter = extraPrefs.keys();
        while (iter.hasNext()) {
            String key = iter.next();
            intent.putExtra(key, extraPrefs.getString(key));
        }
        LOG.d(TAG, "Starting activity %s", className);
        this.cordova.getActivity().startActivity(intent);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        LOG.e(TAG, "Error starting activity %s", className);
    }
}

From source file:com.srikanth.phonegap.ActivityPlugin.java

public void startActivity(String className) {
    try {// ww  w .ja v  a  2 s.  c o m
        Intent intent = new Intent().setClass(this.cordova.getActivity(), Class.forName(className));
        LOG.d(TAG, "Starting activity %s", className);
        this.cordova.getActivity().startActivity(intent);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        LOG.e(TAG, "Error starting activity %s", className);
    }
}