问题描述
我正在编写一个程序来读写xml文件,问题是该程序(我正在调用初始化程序)将被另一个程序(我正在调用计算机)调用,并且该初始化程序具有将一个char数组返回给机器。 这是主要功能:
public static char[] main(String[] args) throws SaxonApiException,IOException,NoSuchMethodException {
define elementos = new define();
if (args.length >= 1) {
file = args[0] + ".xml";
} else {
System.out.print("Não foram enconTrados argumentos\n");
exit(200);
}
Document doc = inicialização.pos.XMLJDomFunctions.lerDocumentoXML(file);
if ("adiciona".equals(args[1])) {
if (args.length >= 3) {
doc = adicionaTabelaFicheiro(args[2].split(" ")[0],args[2].split(" ")[1],doc,elementos);
String c = "0";
return c.tochararray();
}
}
if ("altera".equals(args[1])) {
if (args.length >= 3) {
doc = alteraTabelaFicheiro(args[2].split(" ")[0],elementos);
String c = "0";
return c.tochararray();
}
}
if ("le".equals(args[1])) {
if (args.length >= 3) {
char[] c;
c = leTabela(args[2].split(" ")[0],elementos);
return c;
}
}
String c = "400";
return c.tochararray();
}
如您所见,主类具有char []返回类型,但是当我尝试运行该类时,未找到主类
解决方法
Java中的主要方法必须如下所示:
public static void main(String[] args) {...}
它没有返回类型。如果可能的话,我建议您重命名您的方法。仍然没有记住,必须在某个位置定义main方法才能执行程序。