stjava
stjava

Reputation: 61

Error - Main Class not found

Can't seem to figure out why this simple program has stopped working on my computer. My programs that I compiled up until a Windows update are fine but when I try to compile a new program I get the following. I've attached a picture of the program and the command prompt error message. I've checked the CLASSPATH and it looks fine.

Program - HelloWorldApp.java

class HelloWorldApp{
     public static void main(String[] args){
        System.out.println("Hello World!"); //Display the string
   }
}

execute javac HelloWorldApp.java - all is fine

execute java HelloWorldApp -

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

Please excuse me if this has been answered. I searched but couldn't find this problem

image of notepad program and execution in command prompt

Upvotes: 2

Views: 1158

Answers (1)

amelogenin
amelogenin

Reputation: 351

Have you declared a String class among your list of classes? If so, try using java.lang.String[] args as argument to your main method.

Upvotes: 3

Related Questions