> For the complete documentation index, see [llms.txt](https://heunnajo.gitbook.io/java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://heunnajo.gitbook.io/java/make-multiple-classes-in-one-file.md).

# Make multiple Classes in one file

**File name MUST BE MATCHED WITH Class name which includes main method**

1. If thereis public class, the filename must be matched with public class name!&#x20;

> Hello2.java

```
public class Hello2 {}
       class Hello3 {}
```

If there is no public class, source file name doesn't matter either 'Hello2.java' or 'Hello3.java'

2\. In one source file, there musn't be more than one. Separate class to different source file or remove public from one of them.

> Hello2.java

```
public class Hello2 {}
public class Hello3 {}
```

3\. Uppercase and lowercase does matter even in name. Uppercase in filename, Uppercase in class name as well!

> hello2.java

```
public class Hello2 {}
       class Hello3 {}
```

Recommend  **one** Class in **one** source file.

If source file name and Class name does not match(including Upper/Lower case), it never execute what you want! It just execute randomly.

Control Manually

Run>Run Configuration or Right click on source view>Run As>Run Configuration>Main class: correct the class name to what you want to run. or click "search" button.
