Eclipse编译将大量.class文件放入包文件夹中

发布于 2024-12-24 15:47:52 字数 618 浏览 2 评论 0原文

我一定是做了一些非常愚蠢的事情才导致了下面的情况。基本上,在编译了我之前多次成功编译的代码之后,所有 .class 文件突然都被放入了 .java 文件所在的包文件夹中。一些 .class 文件的名称中包含偶数,例如。

ClassName.java
ClassName.class
ClassName$1.class
ClassName$2.class
ClassName$3.class
ClassName$4.class

它在导航器中看起来一团糟,重建或清理项目并不会让这些文件消失。

我所做的最后一次代码更改(现已恢复)是在类静态字段中:

static {
    if (System.getProperty("os.name").startsWith("Mac OS X")) { CONTROL_PANEL_WIDTH = 225; }
    else { CONTROL_PANEL_WIDTH = 180; }

System.out.println(System.getProperty("os.name")); // this is what I added; perhaps it was stupid
}

我一定做了一些愚蠢的事情。你能帮忙吗?

I must have done something very stupid which has caused the following situation. Basically after compilation of code which I had compiled successfully lots of times previously, all of the .class files have all of a sudden been put in the package folders, where the .java files are. Some of the .class files have even numbers in the names like.

ClassName.java
ClassName.class
ClassName$1.class
ClassName$2.class
ClassName$3.class
ClassName$4.class

It looks a mess in the Navigator and rebuilding or cleaning the project doesn't make these files go away.

The last code change I made, which has now been reverted was in the class static field:

static {
    if (System.getProperty("os.name").startsWith("Mac OS X")) { CONTROL_PANEL_WIDTH = 225; }
    else { CONTROL_PANEL_WIDTH = 180; }

System.out.println(System.getProperty("os.name")); // this is what I added; perhaps it was stupid
}

I must have done something silly. Can you help please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

水溶 2024-12-31 15:47:52

您可能已经切换了类的默认输出文件夹,可以通过右键单击您的项目 -> 来修复该文件夹。 属性 -> Java 构建路径 ->选项卡 -> 默认输出文件夹(将其设置为/bin

您还可以检查工作区中的.classpath 文件,该文件必须查看像这样(输出文件夹的路径是相对存储的):

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

You might have switched your default output folder of your classes, which can be fixed by right click your project -> Properties -> Java Build Path -> Tab Source -> Default Output folder (set it to <ProjectName>/bin)

You could also check the .classpath file in your workspace which have to look like this (the path of the output folder is stored relative):

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
    <classpathentry kind="output" path="bin"/>
</classpath>
我只土不豪 2024-12-31 15:47:52

右键单击您的项目,单击属性

搜索java构建路径,

单击源,这里有类必须所在的配置

不要选中“允许源文件夹的输出文件夹”并检查下面的路径是否正确

Right click on your project, click properties

search for java build path,

click on source, here there is the config where the class must go

Don't check "allow output folders for source folder" and check that the path below is good

彼岸花ソ最美的依靠 2024-12-31 15:47:52

右键单击您的项目。选择构建路径/配置构建路径。选择“源”选项卡。确保默认输出路径不是您的 /src 文件夹。

不知何故,您或 eclipse 设法丢失了编译器的输出文件夹。

Right click your project. Select Build Path / Configure Build Path. Select the Source tab. Ensure that the Default output path is not your /src folder.

Somehow you or eclipse managed to lose the output folder for the compiler.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文