Example usage for java.lang ClassNotFoundException getMessage

List of usage examples for java.lang ClassNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:TestClassForNameNewInstanceApp.java

public static void main(String args[]) {

    try {/*from w  w  w.  j  a  v a  2  s. c  o  m*/
        Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    } catch (ClassNotFoundException e) {
        System.out.println("Oops! Can't find class oracle.jdbc.driver.OracleDriver");
        System.exit(1);
    } catch (IllegalAccessException e) {
        System.out.println("Uh Oh! You can't load oracle.jdbc.driver.OracleDriver");
        System.exit(2);
    } catch (InstantiationException e) {
        System.out.println("Geez! Can't instantiate oracle.jdbc.driver.OracleDriver");
        System.exit(3);
    }

    Connection conn = null;
    Statement stmt = null;
    ResultSet rset = null;
    try {
        conn = DriverManager.getConnection("jdbc:oracle:thin:@dssw2k01:1521:orcl", "scott", "tiger");

        stmt = conn.createStatement();
        rset = stmt.executeQuery("select 'Hello '||USER||'!' result from dual");
        while (rset.next())
            System.out.println(rset.getString(1));
        rset.close();
        rset = null;
        stmt.close();
        stmt = null;
        conn.close();
        conn = null;
    } catch (SQLException e) {
        System.out.println("Darn! A SQL error: " + e.getMessage());
    } finally {
        if (rset != null)
            try {
                rset.close();
            } catch (SQLException ignore) {
            }
        if (stmt != null)
            try {
                stmt.close();
            } catch (SQLException ignore) {
            }
        if (conn != null)
            try {
                conn.close();
            } catch (SQLException ignore) {
            }
    }
}

From source file:fll.subjective.SubjectiveFrame.java

public static void main(final String[] args) {
    LogUtils.initializeLogging();/*  w w  w  .  ja  va 2s. c o m*/

    Thread.setDefaultUncaughtExceptionHandler(new GuiExceptionHandler());

    // Use cross platform look and feel so that things look right all of the
    // time
    try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (final ClassNotFoundException e) {
        LOGGER.warn("Could not find cross platform look and feel class", e);
    } catch (final InstantiationException e) {
        LOGGER.warn("Could not instantiate cross platform look and feel class", e);
    } catch (final IllegalAccessException e) {
        LOGGER.warn("Error loading cross platform look and feel", e);
    } catch (final UnsupportedLookAndFeelException e) {
        LOGGER.warn("Cross platform look and feel unsupported?", e);
    }

    try {
        final SubjectiveFrame frame = new SubjectiveFrame();
        frame.addWindowListener(new WindowAdapter() {
            @Override
            @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK")
            public void windowClosing(final WindowEvent e) {
                System.exit(0);
            }

            @Override
            @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK")
            public void windowClosed(final WindowEvent e) {
                System.exit(0);
            }
        });
        // should be able to watch for window closing, but hidden works
        frame.addComponentListener(new ComponentAdapter() {
            @Override
            @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK")
            public void componentHidden(final ComponentEvent e) {
                System.exit(0);
            }
        });
        GraphicsUtils.centerWindow(frame);
        frame.setVisible(true);
        frame.promptForFile();

    } catch (final Throwable e) {
        JOptionPane.showMessageDialog(null, "Unexpected error: " + e.getMessage(), "Error",
                JOptionPane.ERROR_MESSAGE);
        LOGGER.fatal("Unexpected error", e);
        System.exit(1);
    }
}

From source file:fll.scheduler.SchedulerUI.java

public static void main(final String[] args) {
    LogUtils.initializeLogging();/*from  w  w  w  . j a v a  2  s.c  om*/

    Thread.setDefaultUncaughtExceptionHandler(new GuiExceptionHandler());

    // Use cross platform look and feel so that things look right all of the
    // time
    try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    } catch (final ClassNotFoundException e) {
        LOGGER.warn("Could not find cross platform look and feel class", e);
    } catch (final InstantiationException e) {
        LOGGER.warn("Could not instantiate cross platform look and feel class", e);
    } catch (final IllegalAccessException e) {
        LOGGER.warn("Error loading cross platform look and feel", e);
    } catch (final UnsupportedLookAndFeelException e) {
        LOGGER.warn("Cross platform look and feel unsupported?", e);
    }

    try {
        final SchedulerUI frame = new SchedulerUI();

        frame.addWindowListener(new WindowAdapter() {
            @Override
            @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK")
            public void windowClosing(final WindowEvent e) {
                System.exit(0);
            }

            @Override
            @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK")
            public void windowClosed(final WindowEvent e) {
                System.exit(0);
            }
        });
        // should be able to watch for window closing, but hidden works
        frame.addComponentListener(new ComponentAdapter() {
            @Override
            @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK")
            public void componentHidden(final ComponentEvent e) {
                System.exit(0);
            }
        });

        GraphicsUtils.centerWindow(frame);

        frame.setVisible(true);
    } catch (final Exception e) {
        LOGGER.fatal("Unexpected error", e);
        JOptionPane.showMessageDialog(null,
                "An unexpected error occurred. Please send the log file and a description of what you were doing to the developer. Error message: "
                        + e.getMessage(),
                "Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:Main.java

public static Class<?> getR_ID_Class(Context context) {
    try {//from w  w w . j a va  2  s  .c  o  m
        return Class.forName(context.getPackageName() + ".R$id");
    } catch (ClassNotFoundException e) {
        Log.e("TAG", e.getMessage());
    }
    return null;
}

From source file:org.apache.kylin.common.metrics.perflog.PerfLoggerFactory.java

public static IPerfLogger getPerfLogger(boolean resetPerfLogger) {
    IPerfLogger result = perfLogger.get();
    if (resetPerfLogger || result == null) {
        try {//from ww  w .jav  a  2  s . co m
            result = (IPerfLogger) ClassUtils
                    .getClass(KylinConfig.getInstanceFromEnv().getPerfLoggerClassName()).newInstance();
        } catch (ClassNotFoundException e) {
            LOG.error("Performance Logger Class not found:" + e.getMessage());
            result = new SimplePerfLogger();
        } catch (IllegalAccessException | InstantiationException e) {
            e.printStackTrace();
        }
        perfLogger.set(result);
    }
    return result;
}

From source file:com.canoo.webtest.boundary.StreamBoundary.java

public static Object tryReadObject(final ObjectInputStream ois, final Step step) throws IOException {
    try {//from   w w w .j av a  2  s.c  o m
        return ois.readObject();
    } catch (ClassNotFoundException e) {
        LOG.error(e.getMessage(), e);
        throw new StepExecutionException("Error reading object from file: " + e.getMessage(), step);
    }
}

From source file:com.piusvelte.taplock.client.core.TapLock.java

@SuppressWarnings("rawtypes")
protected static Class getPackageClass(Context context, Class cls) {
    try {/*from  w w  w . j a v a2 s .c  om*/
        return Class.forName(context.getPackageName() + "." + cls.getSimpleName());
    } catch (ClassNotFoundException e) {
        Log.e(TAG, e.getMessage());
    }
    return cls;
}

From source file:org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.HaltedTraverserStrategy.java

public static HaltedTraverserStrategy create(final Configuration configuration) {
    try {// w ww  .j a  va  2  s  .c  o  m
        return new HaltedTraverserStrategy(Class.forName(configuration.getString(HALTED_TRAVERSER_FACTORY)));
    } catch (final ClassNotFoundException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}

From source file:be.vdab.util.Programma.java

private static TreeSet<Voertuig> lees(String file) {//gekozen voor treeSet , zo duidelijk dat er een TreeSet uitkomt (die serialiseerbaar is)
    TreeSet<Voertuig> voertuigen = null;
    ObjectInputStream ois = null;
    try {/*from w ww. j  ava2s  .co m*/
        FileInputStream fis = new FileInputStream(file);
        ois = new ObjectInputStream(fis);
        voertuigen = (TreeSet<Voertuig>) ois.readObject();//je moet exact weten wat er is ingegaan, anders kan je object niet casten naar juiste klasse!?
    } catch (FileNotFoundException fnfe) {
        System.out.println(fnfe.getMessage());
    } catch (IOException ioe) {
        System.out.println(ioe.getMessage());
    } catch (ClassNotFoundException cnfe) {
        System.out.println(cnfe.getMessage());
    } finally {
        try {
            ois.close();
        } catch (IOException ioe) {
            System.err.println(" ioe.getMessage()");
        }
    }

    return voertuigen;
}

From source file:org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.MatchAlgorithmStrategy.java

public static MatchAlgorithmStrategy create(final Configuration configuration) {
    try {//from   www . jav  a  2s .  co m
        return new MatchAlgorithmStrategy((Class) Class.forName(configuration.getString(MATCH_ALGORITHM)));
    } catch (final ClassNotFoundException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}