0
package com.control;

import java.sql.*;

public class DBHelper {

  Connection conn;
  Statement st;
  ResultSet rs;

  public DBHelper() throws ClassNotFoundException {
     Class.forName( "oracle.jdbc.driver.OracleDriver" );
  }

  public boolean getConnection() throws SQLException {
     conn = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:xe" , "system" , "system" );
     if ( conn != null )
        return true;
     return false;
  }

  public void execute( String query ) throws SQLException {
     st = conn.createStatement();
     st.execute( query );

  }

  public static void main( String args[] ) throws Exception {

     DBHelper db = new DBHelper();
     if ( db.getConnection() )
        System.out.println( "Logged In" );
   }
}

I have been trying to run the class with this command :

java -cp "C:\Users\dell\Desktop\MYServlet\WEB-INF\lib\ojdbc5.jar;" com.control.DBHelper

Error: Could not find or load main class com.control.DBHelper

It compiles Sucessfully but doesn't run.

Jared Hooper
  • 881
  • 1
  • 10
  • 31
user5501265
  • 39
  • 1
  • 8
  • Related question: http://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean – Jire Mar 29 '16 at 20:09
  • Have you successfully ran with a manifest? – Jire Mar 29 '16 at 20:11
  • @Jire its not running and what is manifest file ?why do i need it? – user5501265 Mar 30 '16 at 13:03
  • @Jire i noticed that when i compile _javac -d . DBHelper.java_ it compiles and creates folder com/control but in current directory that is in control itself i am compiling my DBHelper.java from control directory. while executing class file structure of my directory is control/com/control/DBHelper.class – user5501265 Mar 30 '16 at 13:15
  • @Jire is there any solution? – user5501265 Mar 31 '16 at 03:10

0 Answers0