关于eclipse:Eclipse-给-Java-应用创建-Run-configuration-时找不到-main-type-的错误消息

27次阅读

共计 1240 个字符,预计需要花费 4 分钟才能阅读完成。

我在 Eclipse 里选中 com 文件夹下选中一个 .java 文件,这个 Java 文件实现了 public static void main(String[] args) 办法,我想作为一个 Java 利用间接运行它。

抉择 Run As -> Java Application

遇到谬误音讯:Selection does not contain a main type:

我抉择 Run Configurations:

New Launch configuration:

创立一个新的 Configuration,却发现找不到 Main Type:

起因可能在于 com 文件夹并没有被 Eclipse 看作是一个 source folder.

把上图的 com 文件夹拖拽到 Java 创立向导主动生成的 src 文件夹内。

呈现了大量的 jco 相干谬误:

把这些编译谬误全副修复后,在 Select type 下拉菜单里就能看到 SimpleCall 了:

总之,只有 source folder 里的 .java 文件能力成为 Main type 搜寻的 candidate:

.classpath 为 Java 编译和压缩文件或我的项目依赖项保护我的项目的源和指标援用。

此配置通过我的项目属性中的 Java 构建门路页面进行保护。源条目能够增加、排序,或者新的 JAR 文件依赖项都能够通过 Java 构建门路页面进行治理。

下图是我一个 jco 我的项目的 .classpath 明细:

其中 source folder,library folder 和 output folder,都定义在 classpathentry 里:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
        <attributes>
            <attribute name="module" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="lib" path="C:/app/sapjco3-ntamd64-3.1.6/sapjco3.jar"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

Eclipse 是插件的运行时环境。实际上,开发人员在 Eclipse 中看到的所有内容都是装置在 Eclipse 上的插件的后果,而不是 Eclipse 自身。

.project 文件由外围 Eclipse 平台保护,其指标是从通用的、独立于插件的 Eclipse 视图中形容我的项目。这个文件负责保护项目名称是什么,它指的是工作区中的其余哪些项目,以及用于构建我的项目的构建器是什么。

正文完
 0