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 Java Basics Getting Started with Java Strings, Variables, and Formatting

import java.io.Console; public class Introductions { Error: Could not find or load main class Introductions.java

I can't seem to run this;

import java.io.Console;

public class Introductions {

public static void main(String[] args) {
    Console console = System.console();
    // Welcome to the Introductions program!  Your code goes below here
   String firstName = "Mary";
  console.printf("Hello, my name is %s\n", firstName);
  console.printf("%s is learning how to code\n", firstName);

}

}

I get the above error..kindly help

Name.java
// I have setup a java.io.Console object for you named console
import java.io.Console;
 public class Introductions {

    public static void main(String[] args) {
        Console console = System.console();
        // Welcome to the Introductions program!  Your code goes below here
       String firstName = "Mary";
      console.printf("Hello, my name is %s\n", firstName);
 }

}

1 Answer

Andrew Elliott
Andrew Elliott
3,306 Points

This challenge isn't asking for the class and console declarations. Take it one step at a time.

Task 1:

Name.java
// I have setup a java.io.Console object for you named console

String firstName = "Mary";

Task 2:

Name.java
// I have setup a java.io.Console object for you named console

String firstName = "Mary";

console.printf("<YOUR NAME> can code in Java!", firstName);

Task 3:

Name.java
// I have setup a java.io.Console object for you named console

String firstName = "Mary";

console.printf("%s can code in Java!", firstName);

But it's good that you knew how to declare classes and imported objects, it's always good to practice things like that.