0

I am trying to write a simple program below.

public class HelloWorld {
    public static void main (String[] args){
        System.out.printIn("Hello, World");
    }
}

I saved the file as "HelloWorld.java" and I navigated to the directory and typed in this command in my terminal javac HelloWorld.java. This created a HelloWorld.class file. I then typed in java HelloWorld in my terminal to run the file and I get this error

"Error: Main method not found in class HelloWorld, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application"

So the error message is telling me I don't have a main method inside the class, I have tried a capital M and lowercase m and I would still get the same error. Does anyone know why this is happening?

2
  • have you save the file? Jul 15, 2019 at 2:09
  • 8
    This does not compile. The method printIn does not exist. It should be println (lowercase "L", not uppercase "I"). Fixing the typo works as expected
    – Phil
    Jul 15, 2019 at 2:11

2 Answers 2

1

You needed a lowercase "L" not an upcase "I". If it helps to remember "println" stands for "print line".

// Copy and paste this to correct your error.
System.out.println("Hello, World");
0

There is a wrong spelling

//System.out.printIn("Hello, World");
System.out.println("Hello, World");

you wrote a capital "I" instead of small "L"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.