Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.

Messy.java
import java.util.*;

public class Messy {
    public   static void main(String[]      args){
System.out.println("five");System.out.println("one");
    System.out.println("six");
    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;
      }
    }}
results.txt

1 Answer

UPDATE

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.