This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Where to Enable the asserions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Where to Enable the asserions" Watch "Where to Enable the asserions" New topic
Author

Where to Enable the asserions

harbir hundal
Greenhorn

Joined: May 07, 2011
Posts: 14

Hi All,

I am a junior developer and developing a web application using Eclipse and the server is JBOSS 6.

I want to know how and where to enable the "assertion", so I can put assertions in my code, and there be the Assertion Errors while developing and testing.

I want to know if I have to do some configuration in Jboss, or some other place.

Any sort of help leading int he right direction will be really appreciated.

Regards
Adofo
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39044
    
  23
Don't know about JBoss.
campbell@queeg:~/java/rubbish$ java KettleDemo
A Kettle, size 20 containing 10 of water.
A Kettle, size . . .
campbell@queeg:~/java/rubbish$ java -ea KettleDemo
A Kettle, size 20 containing 10 of water.
A Kettle, size . . .
I have deleted part of the output; you can copy and paste those classes and execute them and see what really happens.

Note the -ea option. That is the crucial bit. There are other options for assertions.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39044
    
  23
I earlier wrote:. . . There are other options for assertions.
You will find a complete list of options for the "java" tool here.
harbir hundal
Greenhorn

Joined: May 07, 2011
Posts: 14

Hi,

Thank you for your reply Campbell.
I can actually enable the assertion in the java application with the option -ea.
In fact, for eclipse we just need to put "-ea" the JVM variable and the asserions will be turned on for application.

I want to know how can I use assertions in context to web application, that is being deployed in Jboss.
(I should have been more clear)

Regards
Adofo
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39044
    
  23
You use assertions to check the classes for errors before trying to run your application. Do you need assertions when you have got the whole application?
 
GeeCON Prague 2014
 
subject: Where to Enable the asserions