Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8433253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:20:13+00:00 2026-06-10T06:20:13+00:00

public class MainClass { public static void main(String [] args) throws ClassNotFoundException{ //String[] xyz

  • 0
public class MainClass {

    public static void main(String [] args) throws ClassNotFoundException{
            //String[] xyz = {"Client1"};
            List<XmlSuite> suites = new ArrayList<XmlSuite>(); 
            XmlSuite suite=new XmlSuite();

            suite.setName("Demo");

            XmlTest test=new XmlTest(suite);
            List<String> groups=new ArrayList<String>();
            for(String arg:args){
                groups.add(arg);
            }
            List<XmlClass> classes =new ArrayList<XmlClass>();
            System.out.println(Class.forName("TrailAndTest.TestClass"));
            classes.add(new XmlClass(Class.forName("TrailAndTest.TestClass")));

            test.setXmlClasses(classes);
            test.setIncludedGroups(groups);

            suites.add(suite);  

            TestNG tng = new TestNG();
            tng.setXmlSuites(suites);

            tng.run();

        }

}

In my code I have written public class is defined “public class Mainclass” and file is saved with name MainClass.java When I try to execute this code from command prompt i get error:

  1. C:\Selenium\Code\Test\src\TrailAndTest\Mainclass.java:13: class
    MainClass is pub lic, should be declared in a file named
    MainClass.java public class MainClass
    ^ 1 error

Actions performed by me:

C:\Selenium\Code\Test>set path=%path%;”C:\Program
Files\Java\jdk1.5.0_22\bin”

C:\Selenium\Code\Test>set
CLASSPATh="C:\Selenium\Code\Test\bin;C:\Selenium\Code\
Test\Jars\selenium-2.25.0\libs\commons-logging-1.1.1.jar;C:\Selenium\Eclipse\ecl
ipse-jee-indigo-win32-x86_64\eclipse\plugins\org.testng.eclipse_6.7.0.20120808_0
858\libtesting.jar;C:\Selenium\Eclipse\eclipse-jee-indigo-win32-x86_64\eclipse\p
lugins\org.eclipse.wb.runtime.lib_1.5.0.r37x201206111201\lib\cglib-nodep-2.2.jar
;C:\Selenium\ExternalJar\selenium-server-standalone-2.21.0.jar;"

C:\Selenium\Code\Test>javac -sourcepath "C:\Selenium\Code\Test\src" 
"C:\Seleniu m\Code\Test\src\TrailAndTest\Mainclass.java" -d
"C:\Selenium\Code\Test\bin"
C:\Selenium\Code\Test\src\TrailAndTest\Mainclass.java:13: class
MainClass is pub lic, should be declared in a file named
MainClass.java public class MainClass 
             ^ 1 error

C:\Selenium\Code\Test>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:20:14+00:00Added an answer on June 10, 2026 at 6:20 am

    The class and file names are case sensitive. Rename the file to “MainClass.java” with a capital C to match the class name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class Test { public static void main(String[] args) { DemoAbstractClass abstractClass = new
Let's assume I have the following code: public class MainClass { public static void
Why does the following program throw an exception? public class MainClass{ public static void
public class A { private A(int param1, String param2) {} public static A createFromCursor(Cursor
I have a static class (Foo) and a main class (Main) See Main.java: public
Is it OK to reference this when initializing a field? public class MainClass {
I have a main class and two extended classes: class Main { public $foo;
My main class displays a JMenuBar. This JMenuBar is managed from calculator.ui.MenuBar. public JMenuBar
public class MyClass { public string MyProperty{ get; set; } Now, I would like
public class Knowing { static final long tooth = 343L; static long doIT(long tooth)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.