0

I'm a self-taught coder who is new to both Java & Intellij Idea. I wanted to run a simple Java class called payroll in Intellij Idea Ultimate 2017.3

public class payroll {
  public static void main(String[] args) {
    int hours = 50;
    double grossPay, payRate = 25.0;

    grossPay = hours * payRate;
    System.out.println("your gross pay is $" + grossPay);}
  }

Unfortunately IDEA detects some errors indicating that it can't resolve symbols "String" and "System". And when I tried Run/Edit Configuration, the IDE stated that the main method isn't found in the class, but obviously it is declared already

I've used Eclipse & Netbeans before and things just went smoothly then. Can anyone please point out the main cause of this nuisance for me and how to work it out?

Here is the screenshot of the program

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
jack coltrane
  • 71
  • 1
  • 2
  • 6

3 Answers3

1

If core Java lang (java.lang.*) classes cannot be resolved you may need to define the JDK you want to use with IDEA. Here is a link to how to define the JDK (Java Development Kit) you want to use for your project(s): LINK.

You may also need to confirm the JDK path is correct by navigating to the folder and ensuring the JDK version you are using is indeed located there.

Hope this helps!

George Andrews
  • 279
  • 3
  • 9
  • If you find that isn't the issue, you may want to: 1. re-download the JDK, 2. re-add it as the SDK for IDEA, 3. and finally set the project SDK to use it. – George Andrews Dec 07 '17 at 12:16
0

According to the screenshot you have the payroll.java file in src directory.

Try moving that file under src/main/java

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
-2

The class name you should name with Camel-case. That is first. Second. You need to import package for System

Valerii Voronkov
  • 339
  • 1
  • 4
  • 16
  • 1
    "You need to import package for System" why? It is present in the `java.lang` package, no need to import. – VPK Dec 07 '17 at 11:56