我做了应用程序,它说没有main.java。有什么可以修复的吗?
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();
}
}
您不需要main.java。但是,如果您发布的是您的java源代码,请确保编译它,然后在运行它时为java提供必要的类。
如果Java能够找到你的CustomerTest.Java,你可以像这样运行你的代码。它应该位于test/case/business(相对于工作目录(下面,并被称为CustomerTest.class.
java test.cases.business.CustomerTest
如果类位于其他位置,则需要将Java指向同一文件夹结构中托管该类的目录或ZIP/JAR文件,如下所示:
java -cp <path to basedir> test.cases.business.CustomerTest
我不确定你是如何开发和运行你的东西的。IDE可能会让你的生活更轻松。您可能想开始学习OracleJava教程。