【发布时间】:2013-06-27 11:41:39
【问题描述】:
我创建了一个 Java 包 Matrix。当我尝试运行它时,我收到错误“选择不包含主要类型”。但是,正如我从 DriverMatrix 类中复制和粘贴的代码所示,有一个 main 方法声明。我试图重新启动 Eclipse,但仍然出现错误。我创建了名为 Matrix 的包,然后为每个类导入了 .java 文件。有人知道这里发生了什么吗?这是主要声明以及一些代码:
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 来尝试。 -
它是否在源文件夹中的 Java 项目中?
标签: java eclipse import package main