Results 1 to 4 of 4
Like Tree2Likes
  • 1 Post By JosAH
  • 1 Post By jim829

Thread: Could not find or load main class

  1. #1
    karim5623 is offline Member
    Join Date
    Mar 2015
    Posts
    2
    Rep Power
    0

    Default Could not find or load main class

    Hi dear java users,

    I have a very basic problem. I creates this simple code (shown below) inside a package of a major opensource code (i.e., openSHA), but when i run it the following error appears. The error mentions a class named "KT_testGmpeForScenarioRupture" that i wrote before and did not run showing exactly the same error. Could plz kindly let me how can i solve this problem.

    Code:

    package org.opensha.sha.gcim.imr.attenRelImpl;

    public class KT_Test {
    private static void main(String args) {
    int x=4;
    System.out.println("x is " + x);
    }
    }


    Error: Could not find or load main class org.opensha.sha.gcim.imr.attenRelImpl.KT_testGmpeF orScenarioRupture

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: Could not find or load main class

    The main method takes an array of Strings as an argument, not just a single String.

    kind regards,

    Jos
    karim5623 likes this.
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Could not find or load main class

    And main should be declared public, not private.

    Regards,
    Jim
    karim5623 likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  4. #4
    karim5623 is offline Member
    Join Date
    Mar 2015
    Posts
    2
    Rep Power
    0

    Default Re: Could not find or load main class

    Thanks a lot jim829 and JosAH. I appreciate it.

Similar Threads

  1. Cannot find or load or find main class
    By cornelombaard in forum New To Java
    Replies: 3
    Last Post: 11-19-2014, 04:04 PM
  2. Error: Could not find or load main class
    By Georgie23 in forum Eclipse
    Replies: 32
    Last Post: 10-30-2014, 11:44 AM
  3. Error: Could not find or load main class Test.class
    By java_aim in forum New To Java
    Replies: 11
    Last Post: 08-13-2013, 06:05 PM
  4. Replies: 1
    Last Post: 11-29-2012, 10:46 AM
  5. Could not find or load main class
    By kkid in forum New To Java
    Replies: 4
    Last Post: 10-15-2012, 05: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
  •