我已經創建了一個Java包Matrix。當我嘗試運行它時,出現錯誤「選擇不包含主類型」。但是,由於我從DriverMatrix類複製並粘貼的代碼顯示,有一個主要方法聲明。我試圖重新啓動Eclipse,但仍然出現錯誤。我創建了名爲Matrix的包,然後爲每個類導入.java文件。任何人都知道這裏發生了什麼?這裏是主要的聲明只是一個位的代碼一起:嘗試運行Java應用程序時出現Eclipse錯誤 - 「選擇不包含主類型」 - 但它確實如此?
package Matrix;
import java.io.*;
import java.util.Scanner;
public class DriverMatrix
{
static private IntegerArithmetics integerArithmetics = new IntegerArithmetics();
static private DoubleArithmetics doubleArithmetics = new DoubleArithmetics();
public static void main(String[] args) throws FileNotFoundException
{
Scanner inFile = new Scanner (new FileReader("in.txt"));
PrintWriter outFile = new PrintWriter("out.txt");
Matrix<Integer,IntegerArithmetics> matrix1 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,2,3);
Matrix<Integer,IntegerArithmetics> matrix2 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,2,3);
Matrix<Integer,IntegerArithmetics> matrix3 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,2,3);
Matrix<Integer,IntegerArithmetics> matrix4 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,2,3);
Matrix<Integer,IntegerArithmetics> matrix5 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,3,2);
Matrix<Integer,IntegerArithmetics> matrix6 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,2,2);
什麼是完整的錯誤堆棧?它在代碼中引用了哪一行? –
在eclipse中,您可以嘗試右鍵單擊您的類並以「Run as - > Java Application」運行,但是我沒有eclipse來自己嘗試。 –
可能重複:http://stackoverflow.com/questions/8781663/eclipse-returns-error-on-run-java-selection-does-not-contain-a-main-type?rq=1 –