Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试运行Java应用程序时出现Eclipse错误-“;所选内容不包含主类型";-但确实如此?_Java_Eclipse_Import_Package_Main - Fatal编程技术网

尝试运行Java应用程序时出现Eclipse错误-“;所选内容不包含主类型";-但确实如此?

尝试运行Java应用程序时出现Eclipse错误-“;所选内容不包含主类型";-但确实如此?,java,eclipse,import,package,main,Java,Eclipse,Import,Package,Main,我创建了一个Java包Matrix。当我试图运行它时,我得到错误“选择不包含主类型”。但是,正如我从DriverMatrix类复制和粘贴的代码所示,这里有一个主方法声明。我已尝试重新启动Eclipse,但仍然出现错误。我创建了名为Matrix的包,然后为每个类导入.java文件。有人知道这是怎么回事吗?以下是主要声明和一些代码: package Matrix; import java.io.*; import java.util.Scanner; public class DriverMat

我创建了一个Java包Matrix。当我试图运行它时,我得到错误“选择不包含主类型”。但是,正如我从DriverMatrix类复制和粘贴的代码所示,这里有一个主方法声明。我已尝试重新启动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);
包矩阵;
导入java.io.*;
导入java.util.Scanner;
公共类驱动程序
{
静态私有IntegerArithmetics IntegerArithmetics=新IntegerArithmetics();
静态私有DoubleArtimes DoubleArtimes=新的DoubleArtimes();
公共静态void main(字符串[]args)引发FileNotFoundException
{
Scanner infle=新扫描仪(新文件读取器(“in.txt”);
PrintWriter outFile=新的PrintWriter(“out.txt”);
矩阵matrix1=新矩阵(积分数学,2,3);
矩阵2=新矩阵(积分数学,2,3);
矩阵matrix3=新矩阵(积分数学,2,3);
矩阵matrix4=新矩阵(积分数学,2,3);
矩阵matrix5=新矩阵(积分数学,3,2);
矩阵matrix6=新矩阵(积分数学,2,2);

项目中似乎存在
矩阵
类和包名称冲突,可能导致eclipse错误。请尝试重命名其中一个,然后运行应用程序。

项目中似乎存在
矩阵
类和包名称冲突,可能导致eclipse错误。请尝试重命名其中一个然后根据您的代码运行应用程序。

Matrix<Integer,IntegerArithmetics> matrix1 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,2,3);
矩阵matrix1=新矩阵(积分数学,2,3);
似乎有一个包和类的名称都是Matrix。请尝试先更改此名称,因为命名冲突显然会导致错误

来源:

根据您的代码

Matrix<Integer,IntegerArithmetics> matrix1 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,2,3);
矩阵matrix1=新矩阵(积分数学,2,3);
似乎有一个包和类的名称都是Matrix。请尝试先更改此名称,因为命名冲突显然会导致错误


来源:

什么是完整的错误堆栈?它在代码中指的是哪一行?在eclipse中,您可以尝试右键单击您的类和
运行方式->Java应用程序
,但我自己还没有让eclipse来尝试。可能的重复:它是在源文件夹中的Java项目中吗?完整的错误堆栈是什么?它在eclipse中指的是哪一行您的代码?在eclipse中,您可以右键单击您的类和
运行方式->Java应用程序
,但我自己还没有让eclipse来尝试。可能重复:它在源文件夹中的Java项目中吗?谢谢!我刚开始使用eclipse,对Java一般来说是新手。我不知道包的命名约定。谢谢!我刚刚开始使用Eclipse,对Java基本上是新手,我不知道包的命名约定。