Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assertions related

 
achayya matta
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai ranchers
i am presenly using jdk 1.4.2_03.
Can anyone tell me how to compile and run programs?
thanks in advance.
 
Mausam M Kakkad
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

OK, in your version you can run programs with Assertions enabled.

For compiling your program to support "assert" as keyord, you can compile it as

CMD_Prompt>>javac -source 1.4 classname.java //this thing has been added in 1.4 only

for running the program you have to enable the assertion(by default it is disabled). You can enable that for your class as following.

CMD_Prompt>> java -ea classname

This is the most basic syntax for this command. There are various possibilities for enabling/disabling assertions for particular class, package, systemclass etc.

Hope it will help,

Regards,
Mausam
 
Krishna Latha Grandhi
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assertions are disabled by default. To compile with assertions enabled, you need to use the source 1.4 flag:

javac -source 1.4 Test.java

To enable assertions at runtime, use the -enableassertions or -ea flags.

For selective disabling of assertions at runtime, use the -da or -disableassertions flags.

For enabling assertions in the system classes, use the -esa or -dsa flags.
Assertions can also be enabled or disabled on a package basis.

Hope this will help
 
Venkat KG
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ashok,


In General, Assertions are enabled only if you turn on it explicitly.By default they are not enable.

Use '-ea' to enable assertions.

Regards,
Venkat
 
achayya matta
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank u very much guys
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic