即時通訊我試圖讓我的計算器在CMD上工作,但我如何得到它在CMD上工作,但我已經把代碼中的導入和使用。所以我如何讓它在cmd上工作。從java源文件導入到項目(試圖設置導入到類文件進行編譯(java.util.Scanner。和java.Lang.Thread))
繼承人的代碼
import java.util.Scanner;
import java.lang.Thread;
public class Calculator {
int B1;
int C1;
int D1;
@SuppressWarnings("resource")
public static void main(String[] args) throws Exception {
System.out.println("How May i asist you with your calculation.");
Thread.sleep(1000);
System.out.println("So what opperation do you want to use. ");
Scanner A1 = new Scanner(System.in);
String in = A1.nextLine();
if (in.equals("+")){
System.out.println("Enter the first Number. ");
Scanner Z = new Scanner(System.in);
int B1 = Z.nextInt();
System.out.println("Enter The last Number. ");
Scanner Y = new Scanner(System.in);
int C1 = Y.nextInt();
int D1 = B1 + C1;
System.out.println(" you answer is " + D1 + ".");}
else if (in.equals("-")){
System.out.println("Enter the first Number. ");
Scanner Z = new Scanner(System.in);
int B1 = Z.nextInt();
System.out.println("Enter The last Number. ");
Scanner Y = new Scanner(System.in);
int C1 = Y.nextInt();
int D1 = B1 - C1;
System.out.println(" you answer is " + D1 + ".");}
else if (in.equals("*")){
System.out.println("Enter the first Number. ");
Scanner Z = new Scanner(System.in);
int B1 = Z.nextInt();
System.out.println("Enter The last Number. ");
Scanner Y = new Scanner(System.in);
int C1 = Y.nextInt();
int D1 = B1 * C1;
System.out.println(" you answer is " + D1 + ".");}
else if (in.equals("/")){
System.out.println("Enter the first Number. ");
Scanner Z = new Scanner(System.in);
int B1 = Z.nextInt();
System.out.println("Enter The last Number. ");
Scanner Y = new Scanner(System.in);
int C1 = Y.nextInt();
int D1 = B1/C1;
System.out.println("You answer is " + D1 + ".");}
else
System.out.print("That's Not a valid operation.");
}
{
}
}
繼承人上CMD錯誤
異常在線程 「主要」 java.lang.NoClassDefFoundError:工作空間\計算器\ BIN \計算器(錯name:Calculator) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.Se (未知源) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access $ 100(Unknown Source) java.net.URLClassLoader $ 1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source ) 在sun.misc.Launcher $ AppClassLoader.loadClass(來源不明) 在java.lang.ClassLoader.loadClass(來源不明) 在sun.launcher.LauncherHelper.checkAndLoadMain(來源不明)
您正在用錯誤的名稱調用該類:「workspace \ Calculator \ bin \ Calculator「。你用什麼命令來調用它?普通的java? – robermann