What is “src” directory created by Eclipse?

和自甴很熟 提交于 2019-11-28 11:15:10

I would recommend keeping your sources separate from the eclipse workspace, and then use the function:

Import existing project into workspace.

That way you can keep your project under source control, while leaving Eclipse manage its workspace (located elsewhere) on its own.


If you have only sources (anywhere you want), but no Eclipse project, all you need to do create a New Java project, and select your external directory as root directory for your sources.

selecting "Create project from existing sources"

src is where Java IDEs (at least Eclipse and NetBeans) put the source files, it is pretty much standard, and the hierarchy of the folder inside it has to match your Java packages names.

The convention for Java is that your Java files are arranged by namespace under a 'src' directory. So if your application's namespace is com.example.myGame your Java files will be located thus src\com\example\myGame\MyClass.java.

Eclipse attempts to enforce a folder structure that is easy to maintain for all applications. You are not doing anything wrong. But you do have the option to select a different location for your source files but...everyone else expects your source code to be in src so why not.

On the New Project screen you can choose the location where you want your source files or configure the default location if you are not happy with src.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!