我使用「javac LabOne.java」編譯了我的java程序,並且它編造得很糟糕。按照預期,該文件夾中有一個LabOne.java和LabOne.class。但是當我嘗試通過使用「java LabOne」運行程序時,出現錯誤,提示「錯誤:無法找到或加載主類LabOne」。Java - 運行我的java程序錯誤
請有人可以幫助我。
代碼:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package labone;
import java.util.Scanner;
/**
*
*
*/
public class LabOne {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner userInput = new Scanner(System.in);
System.out.println("Welcome To The String Editor!");
System.out.println("");
System.out.println("Please choose what you would like to do by choosing one of the options below:");
System.out.println("1. Input String");
System.out.println("2. Print Current String");
System.out.println("");
int userOption = userInput.nextInt();
String stringInput = new String();
switch (userOption) {
case 1: stringInput = userInput.nextLine();
System.out.println(stringInput);
break;
case 2: System.out.println(stringInput);
break;
default: ;
break;
}
// TODO code application logic here
}
}
請分享您的代碼。 – mkobit 2014-09-21 23:37:59
'labone'或'labOne'? – 2014-09-21 23:38:45
您的錯誤消息顯示「labone」不是「labOne」。 – khelwood 2014-09-21 23:39:14