• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Assertions - command line switches

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't really understand what the ':' is for in the command line switches for using assertions.
What is the ':' in 'java -ea:com.Bar' for?

When is it 'java -ea com.bar' ?

Can anybody explain?

Thanks,

John
 
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can either use the switch with or without arguments. If you use arguments, you always need to use a colon.

Using the switch without arguments means that you enable assertions for all classes, except for system classes. If you arguments, there are two forms:

-ea:com.example...
-ea:com.example.Klass

The first one will enable assertions for class Klass.
The second one will enable assertions for all classes in com.example, and recursively enable assertions for all sub-packages.

"java -ea com.Bar" means run the class Bar with all assertions enabled (except system classes).

"java -ea:com.Bar" means nothing, because you didn't supply a class to run.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:-ea:com.example...
-ea:com.example.Klass

The first one will enable assertions for class Klass.
The second one will enable assertions for all classes in com.example, and recursively enable assertions for all sub-packages.


Have you got that the right way round ?
 
John Stark
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stephan, it is clear now.

John
 
Stephan van Hulst
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joanne Neal wrote:

Stephan van Hulst wrote:-ea:com.example...
-ea:com.example.Klass

The first one will enable assertions for class Klass.
The second one will enable assertions for all classes in com.example, and recursively enable assertions for all sub-packages.


Have you got that the right way round ?


Errr.... woops
 
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Stephan van Hulst wrotes :

-ea:com.example...
-ea:com.example.Klass

The first one will enable assertions for class Klass.
The second one will enable assertions for all classes in com.example, and recursively enable assertions for all sub-packages.




first one is will enable assertion in com.example for all classes .But not for sub-packages Right ??

Second is will enable assertion for class Klass only . Right??
 
Stephan van Hulst
Saloon Keeper
Posts: 15731
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Naveen, that's what Joanne pointed out.
 
Climb the rope! CLIMB THE ROPE! You too tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic