• Post Reply Bookmark Topic Watch Topic
  • New Topic

assertion command doubt  RSS feed

 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java -ea -da:Test , this command is not working ?



Output:

C:\SCJP\Chapter5\assertions\Exercise>javac Test.java

C:\SCJP\Chapter5\assertions\Exercise>java -ea -da:Test
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)

where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
 
Helen Ma
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about this:
java -ea -da:Test Test ?
 
saloni jhanwar
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But why ? , i read this following in K&B.
Selective Enabling and Disabling
The command-line switches for assertions can be used in various ways:

  • With no arguments (as in the preceding examples) Enables or disables assertions in all classes, except for the system classes.


  • With a package name Enables or disables assertions in the package specified, and any packages below this package in the same directory hierarchy (more on that in a moment).


  • With a class name Enables or disables assertions in the class specified.


  • You can combine switches to, say, disable assertions in a single class, but keep them enabled for all others, as follows:

    java -ea -da:com.geeksanonymous.Foo

    The preceding command line tells the JVM to enable assertions in general, but disable them in the class com.geeksanonymous.Foo. You can do the same selectivity for a package as follows:

    java -ea -da:com.geeksanonymous...

    The preceding command line tells the JVM to enable assertions in general, but disable them in the package com.geeksanonymous, and all of its subpackages!
     
    saloni jhanwar
    Ranch Hand
    Posts: 583
    Firefox Browser Notepad Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Helen Ma wrote:How about this:
    java -ea -da:Test Test ?


    I think book need a serious update.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!