File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in code when using assertion

 
Hemant Agarwal
Ranch Hand
Posts: 138
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Now when I tried to compile it this error is coming. I don't know what is its meaning.

A.java:11: warning: as of release 1.4, assert is a keyword, and may not be used
as an identifier
assert j == 2;
^
A.java:11: ';' expected
assert j == 2;
^
1 error
1 warning

I posted this in the beginners form and
I got an answer from Mr. Bastin
Hi Hemant,

While compiling, use "-source 1.4" option.

For Example: If your filename is Abcd.java, compile as
"javac -source 1.4 Abcd.java". You will get the compilation right.


---------------
SCWCD ....ticking.....
SCJP [91%]
---------------

Now how to do this inside an eclipse?

Thanks
Hemant Agarwal
[ February 23, 2006: Message edited by: Hemant Agarwal ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the compiler preferences, disable "default compliance settings" and set the "source compatibility" to 1.4.
 
Hemant Agarwal
Ranch Hand
Posts: 138
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My problem has been solved.
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic