Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Just installed Java: example won't compile (http://www.chiefdelphi.com/forums/showthread.php?t=96803)

de_ 10-08-2011 19:21

Just installed Java: example won't compile
 
Been following the "Getting Started With Java for FRC Doc"
Believe I have installed everything as per pages 1-5
Created robot project as per page 7 (SimpleRobotTemplateProject) but it fails to compile with following error
"<identifier> expected public class 1310Robot extends SimpleRobot"

Noted "import edu.wpi.first.wpilibj.SimpleRobot;" line has an information yellow light bulb saying "Unused Import"

Also if I comment out" package edu.wpi.first.wpilibj.templates;" there is no change in behaviour.

Been stuck a while. Any suggestions ?

Sunstroke 14-08-2011 21:55

Re: Just installed Java: example won't compile
 
So you should definitely keep the package line where it was.

You should also have the top of the class be (after the package declaration and the import stuff):

public class 1310Robot extends SimpleRobot {
...
}

My guess is that you removed the "extends SimpleRobot" part, which would cause the "Unused Import" warning.

de_ 24-11-2011 20:48

Re: Just installed Java: example won't compile
 
(appears to be) Resolved

Changed the name of the class from 1310Robot to T1310Robot (as well as file name and project name) and now it compiles. From this I can only conclude Java must not allow class names starting with numerics and the compiler does not have an error message that reflects that. The error message it put out was highly misleading. Ouch.

linuxboy 25-11-2011 00:08

Re: Just installed Java: example won't compile
 
Quote:

Originally Posted by de_ (Post 1086504)
(appears to be) Resolved

Changed the name of the class from 1310Robot to T1310Robot (as well as file name and project name) and now it compiles. From this I can only conclude Java must not allow class names starting with numerics and the compiler does not have an error message that reflects that. The error message it put out was highly misleading. Ouch.

Yup, thats correct. And the error message is technically meaningful since 1310Robot isn't a valid identifier, its just not specific as to why.

The rules for java naming are:
Start with a letter, underscore, or dollar sign
After that, anything but spaces and special chars
Case sensitive
Can't use a keyword (like class or public)
(Paraphrased from http://mathbits.com/mathbits/java/Da...amingrules.htm)

Oliver

de_ 25-11-2011 13:21

Re: Just installed Java: example won't compile
 
Thanks for the info.

I hate to say having been in programming in just about every language that exists for the past 30 years (except Java), I was hoping compiler messages might have improved over the years and become a little less terse and a little more user useful. Something like "I don't know what "1310Robot" is, it does not start with a letter, $ or underscore" would have saved me many hours of (unpaid voluteer) time that I can not get back (nor my project schedule)@#$%

Looks like I can't count on learning Java rules via the compiler error messages so thanks for the link and I will look around for a good (concise) reference source :)


All times are GMT -5. The time now is 22:17.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi