JMK
JMK

Reputation: 28059

Why is my class not acceptable

This is my first forray into Java, and I am trying to get my head around "Hello World" using Intellij IDEA.

It's not so much the syntax I am having trouble with, more the IDE itself.

First of all, I have downloaded and installed IntelliJ IDEA, and both the 32 bit and 64 bit versions of the Java JDK. IDEA has no trouble finding my Java JDK install, and providing me with intellisense. I have created a test solution named Test, and a src directory to place my source files. My solution explorer looks like this:

Solution Explorer

My Java class is below, it compiles successfully:

public class HelloWorld {

    static void main(String[] args){
        System.out.println("Hello World");
    }


}

I have added the Java JDK to my environmental variables on my computer, and I am able to navigate to the compiled class, and run it in command line. It runs fine.

My issue comes whenever I try and run the class from inside IDEA, for the purposes of debugging. When I click on Run, it asks me to edit my Environmental variables. In the dialogue box that appears, I select Application under Defaults, and try and select HelloWorld as my main class. I get an error telling me that HelloWorld is not acceptable, as shown below:

Error

My question is, how do I run my Java console application inside IDEA for the purpose of debugging? What am I doing wrong?

Upvotes: 24

Views: 25639

Answers (2)

MonoThreaded
MonoThreaded

Reputation: 12043

Dare I admit it?

I overlooked main() parameters!
main(String[] args) is of course the proper signature.

... I am pretty sure that was in Java 101.

Upvotes: 0

Ilya
Ilya

Reputation: 29693

main method should be with public modifier

public static void main(String[] args)

or even better

public static void main( final String[] args )

Upvotes: 47

Related Questions