Results 1 to 3 of 3
  1. #1
    java_aim is offline Member
    Join Date
    Oct 2011
    Posts
    15
    Rep Power
    0

    Default Error: Could not find or load main class Test

    I got the message as the title of this thread shows.
    The program I have written is as follows:

    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.SQLException;
    import javax.swing.JOptionPane;


    public class Test {
    public static void main(String [] args) {
    String connUrl = "jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks2012;use r=sa;password=chai;";
    try {
    Connection conn = DriverManager.getConnection(connUrl);
    }catch(SQLException e) {
    JOptionPane.showMessageDialog(null,e.toString());
    }
    }
    };


    ================================================== =====================

    Can anyone tell me how to fix this and let the compiler find and load the main class Test successfully?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Error: Could not find or load main class Test

    Please use [code] tags [/code] when posting code.

    That is a runtime error, not a compile time error.
    How are you running this?
    Have you compile this already?
    Please do not ask for code as refusal often offends.

  3. #3
    java_aim is offline Member
    Join Date
    Oct 2011
    Posts
    15
    Rep Power
    0

    Default Re: Error: Could not find or load main class Test

    I have compiled this fragment of code already. So I got test.class
    I ran this code by "java Test"

Similar Threads

  1. Error:Could Not Find or Load Main Class
    By vickyv200 in forum New To Java
    Replies: 3
    Last Post: 08-29-2012, 01:10 AM
  2. Error: could not find or load main class
    By sloppygecko in forum New To Java
    Replies: 3
    Last Post: 08-08-2012, 03:11 PM
  3. Error: Could not find or load main class
    By Tybald in forum Eclipse
    Replies: 5
    Last Post: 05-28-2012, 11:22 AM
  4. Replies: 3
    Last Post: 12-09-2011, 03:51 AM
  5. Error: Could not find or load main class
    By ITSlave in forum New To Java
    Replies: 4
    Last Post: 09-15-2011, 09:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •