| Author |
Assertions
|
Jacob Michaels
Ranch Hand
Joined: Mar 23, 2003
Posts: 35
|
|
Does anyone have any tips on how to compile files that use assertions. I can't seem to get mine to work. I am using j2sdk 1.4.1_02 on an XP Home system. I am trying to use a flag: -source 1.4 nameofclass.java but it still won't compile. Any suggestions?? Thanks for any responses.
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
Is the compiler giving any error messages? What exactly do you mean "Won't compile"? Are you really sure a 1.4 compiler is being used? What does java -version say? [ March 30, 2003: Message edited by: Barry Gaunt ]
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
Jacob Michaels
Ranch Hand
Joined: Mar 23, 2003
Posts: 35
|
|
Here is an error message that I get when I try to compile it with TextPad: C:\source\AssertTest.java:5: warning: as of release 1.4, assert is a keyword, and may not be used as an identifier assert i >= 0 : methodB(); ^ C:\source\AssertTest.java:5: ';' expected assert i >= 0 : methodB(); ^ C:\source\AssertTest.java:5: cannot resolve symbol symbol : class assert location: class AssertTest assert i >= 0 : methodB(); ^ C:\source\AssertTest.java:5: i is already defined in methodA(int) assert i >= 0 : methodB();
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
|
It sounds like the -source 1.4 flag isn't being recognized. Since you're using TextPad, I'm guessing the problem may be that TextPad isn't configured correctly (the compile you get by default with control-1 does not have the -source 1.4, unless you reconvifure.) Try going to Configure -> Preferences -> Tools -> Compile Java. Under "Parameters" replace "$File" with "-source 1.4 $File". Hit OK and try again to compile. If it works, you will also need to reconfigure "Run Java" with the -ea option (enable assertions) before you can run with assertions enabled.
|
"I'm not back." - Bill Harding, Twister
|
 |
Jacob Michaels
Ranch Hand
Joined: Mar 23, 2003
Posts: 35
|
|
Thank you! That worked
|
 |
 |
|
|
subject: Assertions
|
|
|