Java Eclipse中出错-找不到Mainclass
我是编程新手,我非常喜欢它。我刚下载了Eclipse,我遇到了一个无法帮助我解决的错误。不幸的是,它是用德语写的,但意思是“找不到主类”-“费勒:Hauptklasse konnte nicht gefunden Order geladen werden” 我知道它与“Java Eclipse中出错-找不到Mainclass,java,eclipse,main,Java,Eclipse,Main,我是编程新手,我非常喜欢它。我刚下载了Eclipse,我遇到了一个无法帮助我解决的错误。不幸的是,它是用德语写的,但意思是“找不到主类”-“费勒:Hauptklasse konnte nicht gefunden Order geladen werden” 我知道它与“publicstaticvoidmain(String[]args)”有关。 因为这对我来说是全新的,所以你能帮助我会很酷 下面的错误源代码 /** * Write a description of class Light he
publicstaticvoidmain(String[]args)
”有关。
因为这对我来说是全新的,所以你能帮助我会很酷
下面的错误源代码
/**
* Write a description of class Light here.
*
* @author (Sunny)
* @version (31.01.2014)
*/
public class Elevator {
// Variables
int maxCarr; // max. carry in KG
int currentCarr; // current state of carry measured in people
boolean fillCondition; // filed or empty - value false = empty
int currentStage; // stage where elevator remains
// Constructor
public Elevator() // initiation
{
maxCarr = 1600;
currentCarr = 0;
fillCondition = false;
currentStage = 0;
System.out.println("**********");
System.out.println("* *");
System.out.println("* *");
System.out.println("* *");
System.out.println("* *");
System.out.println("* *");
System.out.println("* *");
System.out.println("**********");
}
public int (int carry) // Setting carry into the elevator
{
currentCarr = carry;
if (currentCarr != 0) {
fillCondition = true;
return 1;
} else {
return 0;
}
}
public void move(int stage) {
if (stage > currentStage) {
System.out.println("moving up");
currentStage = stage;
} else {
System.out.println("moving down");
currentStage = stage;
}
}
}
当您运行java时,它会运行
main
方法,而我在您的类中没有看到该方法,因此eclipse基本上会告诉您:“您希望我运行什么?”,您应该实现它:
public static void main(String[] args){
// code here
}
当您运行java时,它会运行
main
方法,而我在您的类中没有看到该方法,因此eclipse基本上会告诉您:“您希望我运行什么?”,您应该实现它:
public static void main(String[] args){
// code here
}
我发现了另一个错误
public int (int carry) // Setting carry into the elevator
{
currentCarr = carry;
if (currentCarr != 0) {
fillCondition = true;
return 1;
} else {
return 0;
}
}
方法无法调用'int'。此名称由Java语言保留。我发现另一个错误
public int (int carry) // Setting carry into the elevator
{
currentCarr = carry;
if (currentCarr != 0) {
fillCondition = true;
return 1;
} else {
return 0;
}
}
方法无法调用'int'。Java语言保留了这个名称。在开发核心Java应用程序时,您所需要做的就是在其中包含一个main方法(当然还有功能:p),这是JVM在尝试运行应用程序时搜索的第一个代码片段。对于上述代码,请尝试以下操作:
public static void main (String [] args) {
//Now, make an instance of your class to instantiate it.
Elevator obj = new Elevator();
//Then,as per the desired functionality. Call the methods in your class using the reference.
//obj.move(val of stage);
obj.move(10);
}
只需确保有一个主方法来执行java代码。快乐编码:)在开发核心java应用程序时,您所需要做的就是在其中包含一个main方法(当然还有功能:p),这是JVM在尝试运行应用程序时搜索的第一个代码片段。对于上述代码,请尝试以下操作:
public static void main (String [] args) {
//Now, make an instance of your class to instantiate it.
Elevator obj = new Elevator();
//Then,as per the desired functionality. Call the methods in your class using the reference.
//obj.move(val of stage);
obj.move(10);
}
只需确保有一个主方法来执行java代码。快乐编码:)java的接入点是主要的方法。。每个程序都必须从主方法访问。 在main方法中,您需要创建类的实例,以便在main方法中使用该方法,如下所示:
public static void main(String [] args){
Elevator elevator = new Elevator();
elevator.move(1);
...
}
另外,public int(int carry)//将carry设置到电梯中
在Java中是无效的格式,您必须定义一个方法名,如
public int setCarry(int carry) // Setting carry{
//your code
}
java的访问点是主要方法。。每个程序都必须从主方法访问。 在main方法中,您需要创建类的实例,以便在main方法中使用该方法,如下所示:
public static void main(String [] args){
Elevator elevator = new Elevator();
elevator.move(1);
...
}
另外,public int(int carry)//将carry设置到电梯中
在Java中是无效的格式,您必须定义一个方法名,如
public int setCarry(int carry) // Setting carry{
//your code
}
我们不能运行一个Java程序
public static void main(String[] args) {
}
程序只执行main方法。在main方法中,可以创建如下对象
Elevator elevator = new Elevator();
你可以把main方法放在任何地方。没有main方法,我们就不能运行Java程序
public static void main(String[] args) {
}
程序只执行main方法。在main方法中,可以创建如下对象
Elevator elevator = new Elevator();
您可以将main方法放在任何位置。只需将
publicstaticvoidmain(String[]args){lifter();}
添加到代码中,只需将publicstaticvoidmain(String[]args){lifter();}
添加到代码中即可