This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assertion doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assertion doubt" Watch "Assertion doubt" New topic

Assertion doubt

joshua antony
Ranch Hand

Joined: Jun 05, 2006
Posts: 117
I created a class
When i run using java -ea TestAssertion it runs fine, but if I write
java -ea:TestAssertion the programs does not run. Why?
The colon does not seem to work. Can somebody please explain what I am missing.
Jon Lee
Ranch Hand

Joined: Mar 04, 2005
Posts: 134
Try this

java -ea:WhatTheFxxk? TestAssertion

SCJP 5.0 - 98% (2007)<br />SCWCD 1.4 - 97% (2007)
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
From the documentation of the java command:
-ea[:<package name>"..." | :<class name> ]
Enable assertions. Assertions are disabled by default.

With no arguments, enableassertions or -ea enables assertions. With one argument ending in "...", the switch enables assertions in the specified package and any subpackages. If the argument is simply "...", the switch enables assertions in the unnamed package in the current working directory. With one argument not ending in "...", the switch enables assertions in the specified class.

So your example usage should probably be: java -ea:TestAssertion TestAssertion

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: Assertion doubt
It's not a secret anymore!