I am new to java programming. I kept getting this problem cannot resolve symbol. I really don't know what went wrong. I am using J2SE SDK 1.5 and jGRASP 1.8.3. The code are below. Hope I can get a reply ASAP. Thanks..

1 import java.util.Scanner;
2
3 publicclass Pay
4 {
5 publicstaticvoid main(String[] args)
6 {
7 finaldouble TRANSPORT_ALLOWANCE = 50;
8 double hrRate;
9 int hrsWorked;
10 double pay;
11
12 Scanner scn = new Scanner(System.in);
13
14 System.out.print("Enter the hourly rate: ");
15 hrRate = scn.nextDouble();
16
17 System.out.print("Enter the number of hours worked: ");
18 hrsWorked = scn.nextInt();
19
20
21 pay = hrRate * hrsWorked + TRANSPORT_ALLOWANCE;
22
23 System.out.println ("Pay: " + pay);
24 }
25 }

¼§Pay.java:1: cannot resolve symbol
§symbol : class Scanner
§location: package util
§import java.util.Scanner;
§ ^
¼§Pay.java:12: cannot resolve symbol
§symbol : class Scanner
§location: class Pay
§ Scanner scn = new Scanner(System.in);
§ ^
¼§Pay.java:12: cannot resolve symbol
§symbol : class Scanner
§location: class Pay
§ Scanner scn = new Scanner(System.in);
§ ^
§3 errors
§

Member Avatar for iamthwee

Looks like it doesn't recognise the scanner utility. Are you sure you are linking the java 1.5 development kit properly?

ermm.. what you mean ar? cause i'm new so i not sure about it

Member Avatar for iamthwee

Ok try compiling and running this and see if it works?

hello.java

class hello
{
  public static void main(String[] args)
  {
    System.out.println("hello");
  }
}

Also what operating system are you using? Windows xp, linux, mac?

yah.. can.. i using XP professional

Member Avatar for iamthwee

Well since that works, the only other explanation is that you have not installed the latest java development pack properly, or jgrasp is not reading it.

The java scanner util only works with the very latest versions of the jdk?

You'll have to read the jgrasp documentation to find out how to link it up with jdk 1.5.0.

ok thanks for ur reply. i try and figure out what's wrong. =)

What is the result if you supply java -version from command line?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.