Java编译错误:软件包不存在 [英] Java compile error: package does not exist

查看:326
本文介绍了Java编译错误:软件包不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的工作区(wsPrivate)中,我有3个gradle项目。

In my workspace (wsPrivate) I have 3 gradle projects.


  • Hangman

  • PixelView

  • 报告

Projects PixelView和Reports编译良好。但是Hangman会同时使用这两个项目以及一些在编译时找不到包的方法。

请参见以下错误(在编译Hangman时会弹出):

Projects PixelView and Reports compile fine. However Hangman uses those both projects and some how can't find the packages while compiling.
See the error below (which pop up during compiling Hangman):

D:\_wsGitlab\wsPrivate\Hangman\src\main\java\game\core\Game.java:10: error: package hangman does not exist
import hangman.Messages;
              ^
D:\_wsGitlab\wsPrivate\Hangman\src\main\java\game\core\Game.java:13: error: package viewer does not exist
import viewer.Box;
             ^
D:\_wsGitlab\wsPrivate\Hangman\src\main\java\game\core\Game.java:14: error: package viewer.figures.boxes does not exist
import viewer.figures.boxes.Borders;

我已经阅读了几乎所有关于类路径以及如何解决此问题的信息。 [我的意见]为范围问题,因为我也尝试了多种解决方案,但我认为这会使情况变得更糟。
该程序运行良好,无需在eclipse中进行编译,因此我认为代码枯萎是正确的。

I've read almost every bit of info I could find about classpaths and how to fix this [in my opinion] "scope-problem" as also I've tried multiple solutions but I think I'm making it worse. The program does work fine without compiling in eclipse, so I assume the code withing is correct.

我现在想停留3天,所以如果任何人都可以向我解释我在哪儿行驶的那条路真的很棒。如果需要更多信息,请问:)

I'm now like 3 days stuck on this so if anyone could explain to me where I'm driving of the road that would be really nice. If anymore information is wanted: just ask ;)

因此,这基本上就是我目前所拥有的:

So this is basically what I have at the moment:

我的软件包和添加的库的布局:

Layout of my packages and added library:

我添加到Hangman中的自定义库:

Custom library that I've added to Hangman:

Hangman项目的构建路径上的项目:

Projects on build path of project Hangman:

Hangman项目的订购和出口:

Order and export of project Hangman:

其他两个引用的项目(像素视图/报告):

Other two projects that are referenced (pixelview / reports):

最后但并非最不重要的是我的 build.gradle

Last but not least my build.gradle:

apply plugin: 'application'

mainClassName = "game.core.Game"

repositories {
    jcenter()
}

dependencies {
    compile 'org.apache.commons:commons-math3:3.6.1'
    implementation 'com.google.guava:guava:23.0'
    testImplementation 'junit:junit:4.12'
}

jar {
    baseName = 'HangmanGame'
    version = '2.00.0'
    manifest {
        attributes(
        'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
        'Main-Class': 'game.core.Game'
        )
    }
}


推荐答案

您说您有三个项目-我将其解释为一个Gradle项目,其中包含三个单独的Gradle子项目。

You say you have three projects - I interprete that as one Gradle project with three separate Gradle subprojects.

如果是这样,则需要在根目录下具有 settings.gradle 文件,其内容应为

If so, you need a settings.gradle file at the root level with contents like

include 'Hangman', 'PixelView', 'Reports'

您可以阅读在Gradle文档中详细了解创作多项目Gradle构建

You can read more about authoring multiproject Gradle builds in the Gradle documentation.

这篇关于Java编译错误:软件包不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆