Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my class not acceptable

Tags:

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?

like image 524
JMK Avatar asked Sep 17 '12 17:09

JMK


1 Answers

main method should be with public modifier

public static void main(String[] args) 

or even better

public static void main( final String[] args ) 
like image 200
Ilya Avatar answered Sep 18 '22 16:09

Ilya