0

I did the application and it said that there was no main.java. Is there any I can fix this?

package test.cases.business;

import model.business.Customer;

public class CustomerTest {

    //=======================================
    //Smoke Tests - Construction

    /** Conduct a smoke test for the construction of
     * a Customer with no args
     */
    public void test_newInstance() {
        prn("\n-- test_newInstance --");
        Customer cust = Customer.newInstance();
        prn(cust.toString());
    }

    /** Conduct a smoke test for the construction of
     * a Customer with passed name and phone
     */
    public void test_fromFirstLastPhone() {
        prn("\n-- test_fromFirstLastPhone --");
        Customer cust;
        cust = Customer.fromFirstLastPhone("Asha", "Gupta", "1112223333");
        prn(cust.toString());
    }

    //=======================================
    //Helpers

    public void prn(Object o) {
        System.out.println(o);
    }

    //=======================================
    //Main

    public static void main(String[] args) {
        CustomerTest test = new CustomerTest();
        test.test_newInstance();
        test.test_fromFirstLastPhone();
    }

}
stdunbar
  • 16,263
  • 11
  • 31
  • 53
  • You tagged JavaScript, when it seems you meant Java. I have changed that for you. – evolutionxbox Jan 31 '22 at 23:01
  • 1
    Can you [edit](https://stackoverflow.com/posts/70933860/edit) your post and tell us what you did and the exact error message? How did you compile? – stdunbar Jan 31 '22 at 23:10

1 Answers1

0

You do not need main.java. However if what you posted is your java source code, be sure to compile it, then make the necessary class available to Java when running it.

You can run your code like so given that Java is able to find your CustomerTest.java. It should reside underneath test/cases/business (relative to the working directory) and be called CustomerTest.class.

java test.cases.business.CustomerTest

If the class resides elsewhere, you will need to point Java to the directory or ZIP/JAR file hosting that class in the same folder stucture like so:

java -cp <path to basedir> test.cases.business.CustomerTest

I am not sure how you develop and run your stuff. An IDE might make your life easier. You might want to get started with the Oracle Java tutorial.

Queeg
  • 7,748
  • 1
  • 16
  • 42
  • This is where I save my file. How do I add java test.cases.business.CustomerTest? and if you go up you can see I add an image to show where I store my files. – user16284724 Feb 01 '22 at 03:03