3

This is my first time coding, so I'm sorry if I caused you to facepalm.

I wanted to use the Scanner class to read the user input. However, I get an error. I've stopped coding when I faced this problem, thus the code is far from done, but this is what I have:

package trigger;
import java.util.Scanner;
public class Trigger {
    public static void main(String[] args) {

        System.out.println("Please input known values");
        Scanner input = new Scanner(System.in);

        System.out.println("Angle A");
        String Ain = input.next();

        System.out.println("Angle B");
        String Bin = input.next();

        System.out.println("Angle C");
        String Cin = input.next();

        System.out.println("Side A");
        String ain = input.next();

        System.out.println("Side B");
        String bin = input.next();

        System.out.println("Side C");
        String cin = input.next();

    }
}

That returns a error like this:

java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Uncompilable source code - cannot find symbol
symbol:   class Scanner
location: class java.util
at trigger.Trigger.<clinit>(Trigger.java:2)
Exception in thread "main" C:\Users\******\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)

I've read some things online, and learned that the Scanner class is only supported in java 1.5 and up. However, I should have JDK 1.8. I am using NetBeans IDE 8.1.

If anyone can help me with this, that will be amazing. Thanks in advance!

EDIT: I've made sure the "Source/Binary Format" under "Sources" in "Project Properties" is set to JDK 8, yet the problem persists.

mjn
  • 36,362
  • 28
  • 176
  • 378
Vizor
  • 73
  • 1
  • 1
  • 6
  • 5
    You need to confirm your IDE settings are set to use the 1.8 compiler. – ck1 Jun 11 '16 at 13:28
  • 3
    I can't begin to imagine how you managed to cause something so elementary to not work. – Boann Jun 11 '16 at 13:35
  • You should be able to right-click and set this in Project Properties. Another solution might be to ensure NetBeans is running JDK 1.8 by using the `--jdkhome` option described here: http://wiki.netbeans.org/FaqJdkHome – ck1 Jun 11 '16 at 13:36
  • Ok... I looked at the "Source/Binary Format" in the Project Properties, and made sure that it was set to "JDK 8"... Yet I still get the same error. – Vizor Jun 11 '16 at 13:38
  • @Boann when it comes to IDE "surprises", imagination is an underrated soft skill :) – mjn Jun 11 '16 at 14:58

1 Answers1

6

Try to uncheck "Compile on save" setting in the project properties (Build -> Compiling)

thangdc94
  • 1,542
  • 2
  • 26
  • 38
  • Thanks! That allowed it to run. I will see if it is working..(I still have the "cannot find symbol" error message at the side) – Vizor Jun 11 '16 at 13:58