Guest User

Untitled

a guest
Oct 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. package com.javamultiplex.java.lang.exceptions;
  2.  
  3. /**
  4. * @author Rohit Agarwal
  5. * @version 1.0
  6. * @category java.lang/Exception
  7. * @since JDK 1.0
  8. */
  9. public class ClassNotFoundExceptionDemo {
  10.  
  11. public static void main(String[] args) {
  12.  
  13. try {
  14. /*
  15. * ClassNotFoundException will be thrown because OracleJdbcDriver
  16. * class is not present in classpath.
  17. */
  18.  
  19. // Method 1
  20. Class.forName("oracle.jdbc.OracleJdbcDriver");
  21.  
  22. // Method 2
  23. ClassLoader classLoader = ClassLoader.getSystemClassLoader();
  24. classLoader.loadClass("oracle.jdbc.OracleJdbcDriver");
  25.  
  26. } catch (ClassNotFoundException e) {
  27. e.printStackTrace();
  28. }
  29.  
  30. }
  31.  
  32. }
Add Comment
Please, Sign In to add comment