Idea Right button cannot create new Java Class

Source: Internet
Author: User

After creating a new directory in the project, to add a Java class file to the directory, right-click New finds no corresponding option.

Cause: After creating the directory, you need to set the directory role so that idea can be identified.

Method: File-project Structure

The following are explained for several directory types:

  • Sources: Generally used for labeling similar src to such a compiled directory. Sometimes we don't just have src to compile the directory of the project, there are some other special directories that we might want to use as a compiled directory, and we need to label that directory. This Sources is the only kind of compiled catalog that can create new Java classes and packages, which you need to keep in mind.
  • Tests: Typically used to label a compiled unit test catalog. In the canonical MAVEN project structure, the top-level directory is src , maven src We are not set to Sources , but in its subdirectory directory under the directory main java we will set as Sources . The directory where the unit tests are, we set the directory as a src - test - java java Tests compiled unit test directory. Generally this and the next few of us are configured under the MAVEN project, but I'll talk about it first. From this we can also see that IntelliJ idea's support for the MAVEN project is more than thorough.
  • Resources: typically used to label resource file directories. Under the MAVEN project, the resource directory is separate, and its directory is: src - main -resources , here's the resources directory we will set to Resources , indicating that the directory is as a resource directory. The files under the resource directory are compiled into the output directory.
  • Test Resources :A directory of resource files typically used for labeling unit tests. Under the MAVEN project, the Resource directory for unit tests is separate, and the directory is: here we set the directory as the src - test -resources resources Test Resources Resource directory for unit tests. The files under the resource directory are compiled into the output directory.
  • Excluded: Generally used to label exclude directories. Excluded directories are not indexed by IntelliJ idea, which is equivalent to being discarded by IntelliJ idea, which is a code file that does not have regular code features such as code checking and smart hints.

With the above introduction, we know that for non-MAVEN projects we just have to set it up src .

The annotated directory will have a general summary on the right. classesAlthough it is a Excluded directory, but it has a special, can not be shown here.

Idea Right button cannot create new Java Class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.