This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Assertions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Assertions" Watch "Assertions" New topic
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: 18671
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assertions
 
Similar Threads
Java 1.4
Enabling Assertions
enableassertions
assertions
Assertions