gpt4 book ai didi

java - 使用 public static main(String args) 执行 PerformExecute()

转载 作者:行者123 更新时间:2023-12-01 18:46:23 25 4
gpt4 key购买 nike

 public class XGetProgramGuideDirectTestControllerCmdImpl extends ControllerCommandImpl implements XGetProgramGuideDirectTestControllerCmd {
public final String CLASSNAME = this.getClass().getName();
public void performExecute() throws ECException { /* code is here*/ }

private void callUSInterface() throws ECException { /* code is here*/ }

private void callDEInterface() throws ECException { /* code is here*/ }

private void callUKInterface() throws ECException { /* code is here*/ }

public void setRequestProperties(TypedProperty req) throws ECException { /* code is here*/ }

private void displayResponse(StringBuffer testResult) { /* code is here*/ }

public static void main(String[] args) {
XGetProgramGuideDirectTestControllerCmdImpl PGDirTestController = new XGetProgramGuideDirectTestControllerCmdImpl();
PGDirTestController.performExecute();
}

}

我只是尝试使用 public static void main(String[] args) 在 Eclipse-RAD 中将此应用程序作为 java 应用程序运行,但它给了我一个错误:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
Unhandled exception type ECException

关于:

PGDirTestController.performExecute();

请放轻松,我对 Java 还很陌生。

最佳答案

自您声明以来:

public void performExecute() throws ECException 

然后你被迫处理ECException

因此,当您调用它时,应该用 try-catch 包围它,或者声明调用它的方法以抛出异常:

public static void main(String[] args) {
XGetProgramGuideDirectTestControllerCmdImpl PGDirTestController = new
XGetProgramGuideDirectTestControllerCmdImpl();
try {
PGDirTestController.performExecute();
} catch(ECException e) {
e.printStackTrace();
//Handle the exception!
}
}

或者

public static void main(String[] args) throws ECException {
XGetProgramGuideDirectTestControllerCmdImpl PGDirTestController = new
XGetProgramGuideDirectTestControllerCmdImpl();
PGDirTestController.performExecute();
}

关于java - 使用 public static main(String args) 执行 PerformExecute(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17594684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com