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

Assertion doubt

 
joshua antony
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a class TestAssertion.java
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
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this

java -ea:WhatTheFxxk? TestAssertion
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic