aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Error in code when using assertion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Error in code when using assertion " Watch "Error in code when using assertion " New topic
Author

Error in code when using assertion

Hemant Agarwal
Ranch Hand

Joined: Nov 21, 2005
Posts: 138


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

Joined: Jul 11, 2001
Posts: 14112
In the compiler preferences, disable "default compliance settings" and set the "source compatibility" to 1.4.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Hemant Agarwal
Ranch Hand

Joined: Nov 21, 2005
Posts: 138
My problem has been solved.
Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error in code when using assertion