未找到主要方法、小程序或 MIDlet (No main methods, applets, or MIDlets found)


問題描述

未找到主要方法、小程序或 MIDlet (No main methods, applets, or MIDlets found)

當我運行此程序時,會出現一個彈出窗口,告訴我沒有找到主要方法、小程序或 MIDlet。有人可以告訴我為什麼嗎?‑‑我正在使用 jGrasp。我正在嘗試使用 main 方法,但我之前沒有遇到過這個問題。

import java.util.*;
import java.io.*;


public class ProgrammingExercise3.1
{
   public static void main(String[] args);
   {

      double rectWidth;
      double rectLength;
      double radius;
      int age;
      double begBal;
      char A;
      String name;
      double rate;

      scanner inFile = new Scanner(new FileReader("C:\\Users\\sierr_000\\Desktop\\Sam School\\IT‑145\\Exercises\\Ch 3\\inData.txt"));

      PrintWriter outFile = new PrintWriter("C:\\Users\\sierr_000\\Desktop\\Sam School\\IT‑145\\Exercises\\Ch 3\\outData.out");

      rectWidth = inFile.next();
      rectLength = inFile.next();

      outFile.println("Rectangle: ")
      outFile.println("Length = " + rectLength + ", width = " + rectWidth + ", area = "
                     + (rectWidth*rectLength) + ", perimeter = " + (2 * (rectwidth + rectLengh)));

      radius = inFile.next();

      outFile.println("Circle: ");
      outfile.println("Radius = " + radius + ", area = " + (radius*3.1416) + "Circumfrence = " + (2*3.1416*radius));

      name = inFile.next();
      age = inFile.next();
      begBal = inFile.next();
      rate = inFile.next();

      outFile.println("Name: " + name + ", age: " + age);
      outFile.printf("Beginning Balance: %7.2f" , begBal + "interest rate: %4.2f" , rate);
      outFile.println("The character that comes after A in the ASCII is B");      




      inFile.close();
      outFile.close();

   }
}   

參考解法

方法 1:

This seems to be full of errors, but the main reason you are getting that error is that you put a semicolon after public static void main(String[] args).

(by Samuel Wyatt CassadyACCFfan)

參考文件

  1. No main methods, applets, or MIDlets found (CC BY‑SA 2.5/3.0/4.0)

#java #jgrasp #main-method






相關問題

電子郵件地址中帶有 + 字符的 Java 郵件 (Java mail with + character in email address)

如何快速原型化 Java 代碼? (How to quickly prototype Java code?)

如何使用 Maven 在目標(SVN-)服務器上創建 Javadoc? (How to create Javadoc on the target (SVN-) server using Maven?)

為什麼檢查二叉樹有效性的解決方案不起作用? (Why the solution for checking the validity of binary tree is not working?)

Selenium webdriver通過第一個數字找到texy (Selenium webdriver find texy by first digits)

setOnClickListener 沒有在圖像視圖上被調用 (setOnClickListener is not getting called on image view)

繪製多邊形:找不到錯誤 (Drawing Polygon : unable to find error)

半透明 JButton:對像出現在背景中 (Semi-Transparent JButton: Objects appear in Background)

比較同一數組的元素 (Compare elements of the same array)

Java 屏幕截圖小程序 (Java screen capture applet)

Minecraft 1.8.9 Forge Modding 的Java 開發工具包,需要什麼JDK/JRE,代碼是否正確? (Java Development Kit with Minecraft 1.8.9 Forge Modding, What JDK/JRE Is Needed, Is Code Correct?)

java while (resultset.next()) 不返回同一列中的所有數據 (java while (resultset.next()) does not return all data in the same column)







留言討論