如何在 Eclipse 中更改 Java 项目的 bin 文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3191693/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 19:30:10  来源:igfitidea点击:

How do I change a Java project's bin folder in Eclipse?

eclipse

提问by Chris J

When you have a Java project in Eclipse, how do you change the location where the class files are placed? The bin directory is the default location.

当您在 Eclipse 中有一个 Java 项目时,您如何更改放置类文件的位置?bin 目录是默认位置。

回答by User 1034

You can change the folder name from bin to something else.

您可以将文件夹名称从 bin 更改为其他名称。

Right click on your project and select Properties. And then click on Java Build Path. On the right side you can see the tabs Source, Projects, Libraries,...

右键单击您的项目并选择Properties。然后点击Java Build Path。在右侧,您可以看到选项卡Source, Projects, Libraries,...

Click on Source. Check the Default output folder:. There you can browse and select the different folder you want.

单击Source。检查Default output folder:. 您可以在那里浏览并选择所需的不同文件夹。

But you cannot change the directory. For example if your project is in D: drive you cannot keep the output folder in C: drive.

但是您不能更改目录。例如,如果您的项目在 D: 驱动器中,则不能将输出文件夹保留在 C: 驱动器中。

回答by eSniff

Right-click on our project --> select properties--> select Java Build Path--> select the Source tab. At the bottom of the tab you should see a field named (Default Output Folder:).

右键单击我们的项目 --> 选择属性--> 选择Java Build Path--> 选择Source 选项卡。在选项卡的底部,您应该看到一个名为(默认输出文件夹:)的字段。

回答by Sumit Singh

Right click on your project and select Properties.

右键单击您的项目并选择属性。

Java Build Path --> select the Source tab

See the below image for more details:

有关更多详细信息,请参阅下图:

enter image description here

在此处输入图片说明

回答by ashjtech

I would like to describe an approach below.

我想在下面描述一种方法。

First, create a new empty projectlocally in eclipse work space for storing generated output files say output_bin.

首先,在 eclipse 工作空间中本地创建一个新的空项目,用于存储生成的输出文件,比如 output_bin。

As mentioned in above steps, now from Default Output Folderwe need a new Variable to link to our project output folder.

如上所述,现在从默认输出文件夹中,我们需要一个新变量来链接到我们的项目输出文件夹。

  1. Default Output Folder -> Browse -> Create New Folder...
  2. -> Advance -> check "Link to folder in the file system" ->
  3. Variables-> New.. -> Name = PROJECT_OUT, Location = "CHOOSE_PATH_TO\output_bin\bin\Project1bin" -> Ok
  1. 默认输出文件夹 -> 浏览 ->创建新文件夹...
  2. -> 前进 -> 勾选“链接到文件系统中的文件夹”->
  3. 变量-> 新建.. -> 名称 = PROJECT_OUT,位置 = " CHOOSE_PATH_TO\output_bin\bin\Project1bin" -> 好的

Note: Project1bin is a new directory which stores the bin folder. output_bin is an empty project and you can have multiple bin folder for various projects.

注意:Project1bin 是一个新目录,用于存储 bin 文件夹。output_bin 是一个空项目,您可以为各种项目设置多个 bin 文件夹。

回答by mike rodent

These answers only describe changing for one specific project.

这些答案仅描述了一个特定项目的更改。

But if you are using a build tool in Eclipse such as Gradle, you are likely to get annoyed by spurious build errors caused by class files being produced under \bin... the best thing is therefore to change the defaultoutput folder:

但是,如果您在 Eclipse 中使用构建工具(例如 Gradle),您可能会对 \bin 下生成的类文件导致的虚假构建错误感到恼火……因此,最好的方法是更改默认输出文件夹:

(Eclipse Mars)
Window --> Preferences --> Java --> Build Path --> Output folder name: change from "bin" to "build"
NB be aware, however, that this (currently) only appears to work when you create a new Java project using the Java project wizard. I import Gradle (STS) projects and find that I nevertheless have to change manually from "bin" to "build" for each project.

(Eclipse Mars)
窗口 --> 首选项 --> Java --> 构建路径 --> 输出文件夹名称:从“bin”更改为“build”
注意,但是,这(当前)仅在以下情况下才起作用您使用 Java 项目向导创建一个新的 Java 项目。我导入 Gradle (STS) 项目并发现我仍然必须为每个项目手动从“bin”更改为“build”。