Search code examples
javaintellij-ideajavac

Compiling java inner class in IntelliJ: where's the class file?


Considering the following code:

public class Book {
    private int pageNumber;
    public class BookReader {
        public int getPage() {
            return pageNumber;
        }
    }
}

If this code is compiled using commandline

javac Book.java

it should result in two class files: Book.class and Book$BookReader.class. And it does. But when I load this piece of code into an IDE such as IntelliJ, the resulting class file is only Book.class. Just out of curiosity, does anyone know what's going on here? I'm prepping up for an exam and stuff like this can make me go crazy!


Solution

  • IntelliJ IDEA hides the inner class files in the output paths of the Project View, but the file will be there on disk. You can right click on the .class file and choose Show In Explorer, then you'll see the inner class file.