【发布时间】:2014-11-15 21:08:49
【问题描述】:
我使用“javac LabOne.java”编译了我的 java 程序,它成功地编译了。现在在那个文件夹中有一个 LabOne.java 和 LabOne.class 正如预期的那样。但是当我尝试使用“java LabOne”运行程序时,我收到一条错误消息“错误:无法找到或加载主类 LabOne”。
请有人帮助我。
代码:
/*
* 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
}
}
【问题讨论】:
-
请分享您的代码。
-
labone或labOne? -
您的错误消息显示“labone”而不是“labOne”。
-
即使您的操作系统(如 Windows)不区分大小写,Java 也是。
-
您的课程在 labOne 包中。以
java labOne.LabOne运行,并从正确的目录运行,即labOne 目录所在的目录。
标签: java