• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

assertion

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi...

I tried to run many codes of assertion with packages declarations...i search many sites & also read kieth sierra but the option to run from cmd are not running.

i want to enable assertion in a class which is under hirerachy of package.

can anyone give me an example.

my example:-

package abc1.abc11.abc111;

class D
{
public static void main(String[] args) {
go(true);
}

static void go(boolean y){
int x = 2;
assert(x==1);
System.out.println("Hello World!");

}
}

in cmd i write the command...

java -ea:abc1.abc11.abc111... D

its not running..

thanks in advance

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

aashi dubey wrote:java -ea:abc1.abc11.abc111... D


When you run a class that is in a package from the command line, you have to first make sure that the base directory of the package hierarchy is in the classpath, and then you'll have to provide the fully-qualified name of the class to the java command. You're just specifying the simple classname "D" instead of the fully-qualified name "abc1.abc11.abc111.D".

Assuming your current directory is the base directory of the package hierarchy, this should work:

java -ea:abc1.abc11.abc111... abc1.abc11.abc111.D

aashi dubey wrote:its not running..


Always tell us exactly what error you get instead of just saying "it doesn't work" - the error message contains important information which explains exactly what the problem is.
 
aashi dubey
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i m getting class not found exception.
 
aashi dubey
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks its running now...
 
Beauty is in the eye of the tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic