newbie question (i think)

M

malorykay

Alright. So, I just had my second Computer Science class, and I'm
already stumped. This is the situation: I did an assignment on a PC,
very simple java. Used jGrasp to compile and run, everything was fine.
Then I tried to do the exact same thing on my Mac, using jGrasp. I get
a bunch of error messages that weren't on the pc, like

SalesTax.java:3: cannot resolve symbol
symbol : class Scanner
location: package util
import java.util.Scanner;


I am using Java 5.0, and even though I set the preferences so that 5.0
is the version in use, aren't these errors that would have come up in
Java 1.4? I've double and triple checked, and everything appears right.
My professor doesn't know either (she is not a mac person) and my
school's tech help is completely ineffective.

Any help thrown this way would be very very much apperciated.
 
T

Thomas Hawtin

SalesTax.java:3: cannot resolve symbol
symbol : class Scanner
location: package util
import java.util.Scanner;
I am using Java 5.0, and even though I set the preferences so that 5.0
is the version in use, aren't these errors that would have come up in
Java 1.4? I've double and triple checked, and everything appears right.

Yes, java.util.Scanner is not in 1.4. If you set -target 1.5 or -source
1.5 (the default) then 1.4 shouldn't even attempt to run it.
My professor doesn't know either (she is not a mac person) and my
school's tech help is completely ineffective.

System.getProperty("java.version") should return a JRE version string.

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperties()

Tom Hawtin
 
R

Roedy Green

Yes, java.util.Scanner is not in 1.4. If you set -target 1.5 or -source
1.5 (the default) then 1.4 shouldn't even attempt to run it.

In a perfect world yes. But -target 1.4 does not stop you from running
missing classes and methods. You don't find out till run time, as I
discovered to my dismay on Component.setMaximumSize.
 
R

Roedy Green

SalesTax.java:3: cannot resolve symbol
symbol : class Scanner
location: package util
import java.util.Scanner;

Two things: as a newbie, post to comp.lang.java.help rather than
comp.lang.java.programmer. You will find the reception warmer.

Post your code. It will be far more eloquent than you at explaining
your problem. There are a millions things you could have done wrong
that we could never guess without seeing your code.
 
T

Thomas Hawtin

Roedy said:
In a perfect world yes. But -target 1.4 does not stop you from running
missing classes and methods. You don't find out till run time, as I
discovered to my dismay on Component.setMaximumSize.

I suggested the other way about. Making sure javac is producing code
that *will not* be understood by old JREs.

But yeah, if you're compiling for older targets set all of -source,
-target and -Xbootclasspath. The default options on JDKs 1.1-1.4 are not
consistent.

Tom Hawtin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top