aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assertions related Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assertions related" Watch "Assertions related" New topic
Author

Assertions related

achayya matta
Ranch Hand

Joined: Oct 27, 2005
Posts: 111
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

Joined: Oct 27, 2005
Posts: 40
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

Joined: Nov 08, 2005
Posts: 110
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

Joined: Nov 13, 2005
Posts: 10
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

Joined: Oct 27, 2005
Posts: 111
thank u very much guys
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assertions related