Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Local Development Environments Exploring Your IDE Clean up this mess

My class isnt found when running this in Intellij

N.B. The code attached to this is the 'messy' file and is the code that this challenge is asking us to resolve locally through IntelliJ.

I am currently on the introduction to IntelliJ and how it operates and have came across an issue trying to run the code in there for this exercise.

I have followed the steps of this exercise carefully, formatting the text etc and now am stuck not being able to run the file due to the class not being noticed.

I searched the error thrown in the console

java.lang.ClassNotFoundException: Messy

it is suggesting that the JVM (Java Virtual Machine) cant find it in the classpath but the file is there under the src folder.

I see two options to the best of my knowledge:

Either I force the class to work in the console like in a previous exercise, but have, of course just started using Intellij and have no clue how to do that yet.

Or I needed to create this file as a 'Java Class' file and not just a standard 'Java' file.

Any advice on this would be much appreciated.

import java.util.*;

public class Messy {
    public   static void main(String[]      args){
    System.out.println( "four"       );     System.out.println("two");
    Please comment out this line and
    this line as well with a hotkey that does multi-line commenting
    List<String> numberWords = Arrays.asList("six", "seven", "eight", "nine");
    for (String numberWord:         numberWords) {
      // Use the sout shortcut to write out numberWord;

1 Answer


Ive cracked it.

It IS 'java class' you use NOT a normal 'java' file when creating this file in IntelliJ for part 4 of this challenge!!!

The code now runs as expected.