Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javamultiplex.java.lang.exceptions;
- /**
- * @author Rohit Agarwal
- * @version 1.0
- * @category java.lang/Exception
- * @since JDK 1.0
- */
- public class ClassNotFoundExceptionDemo {
- public static void main(String[] args) {
- try {
- /*
- * ClassNotFoundException will be thrown because OracleJdbcDriver
- * class is not present in classpath.
- */
- // Method 1
- Class.forName("oracle.jdbc.OracleJdbcDriver");
- // Method 2
- ClassLoader classLoader = ClassLoader.getSystemClassLoader();
- classLoader.loadClass("oracle.jdbc.OracleJdbcDriver");
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment