*
The moose likes Programmer Certification (SCJP/OCPJP) 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assertions" Watch "Assertions" New topic
Author

Assertions

Osama Hasan
Greenhorn

Joined: Sep 22, 2002
Posts: 7
Article of


Any of the following commands enables assertion checking in class Foo:
1)java -ea Foo
2)java -ea:Foo Foo
3)java -ea:... Foo

I understood what 1 and 3 do.But what's the purpose bof writing the classname(Foo) two times in command no. 2.
Can any one explain?
Thanx in advance.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Osama, please change your display name to meet the JavaRanch naming requirements. You must use first name - space - last name.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Shishio San
Ranch Hand

Joined: Aug 29, 2002
Posts: 223



I understood what 1 and 3 do.But what's the purpose bof writing the classname(Foo) two times in command no. 2.
Can any one explain?
Thanx in advance.

I think you mistyped the name of your class i.e Foo1 instead of Foo. Anyway the following command
java -ea:Foo Foo
runs the program called Foo with Assertions enable only in package Foo and its subpackages.
you might have a package called Foo then.


Whatever doesn't kill us ...<br />Is probably circling back for another try.<br />SCJP 1.4
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Originally posted by Thomas Paul:
Osama, please change your display name to meet the JavaRanch naming requirements. You must use first name - space - last name.

And here is the link:
Change your displayed name here


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Osama Hasan
Greenhorn

Joined: Sep 22, 2002
Posts: 7
I am still confused.
I am running class Foo with the command line:
java -ea:Foo Foo
Although class Foo is not in the package "Foo" but still class Foo is running with assertions enabled.
Jussi Sairanen
Greenhorn

Joined: Oct 09, 2002
Posts: 1
Thought I'm not a professional on this particular issue, a quick search on the web found me this functionality for -ea:
<cut>
no arguments
Enables or disables assertions in all classes except system classes.
packageName...
Enables or disables assertions in the named package and any subpackages.
...
Enables or disables assertions in the unnamed package in the current working directory.
className
Enables or disables assertions in the named class
<cut>
--------------------
So java -ea:Foo Foo enables assertions for _class_ Foo not package, and runs the program Foo.

Jussi Sairanen
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Assertions
 
Similar Threads
Where did it go wrong?--1
problem in when to use this in java
static method invocation problem
Assertion Question