• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Enable assertion on a package  RSS feed

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the OCP book : by Jeanne Boyarsky and Scott Selikoff it is said that this command will be used to enable assertion for classes in the package and sub-package :
(Chap6 is the package name and AssertionTest is the class name that contains a main function), however when I execut this code I get an error telling that the class AssertionTest is not found.
Does anyone detected what I missed ??
 
Saloon Keeper
Posts: 9385
181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you compile the code?
 
yas sine
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
of course, I run "java c" command before
 
Stephan van Hulst
Saloon Keeper
Posts: 9385
181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us the code, and write out the exact commands you use to compile and run it, as well as the current working folder that you run the commands from?
 
yas sine
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the code :

here is the commades that I use :

javac AssertionTest.java
java ea:chap6 AssertionTest


 
author & internet detective
Marshal
Posts: 38684
677
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the book (page 310), it shows that you include the package name when running code in a package.  For example,


So you need to have chap6.AssertionTest.

Interesting, you should get that same error even without the -ea flag because you are trying to run the class without a package name.
 
yas sine
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried :
java -ea:chap6.AssertionTest
(and  java -ea chap6.AssertionTest)
but it doesn't work, I still get the class not found exception

 
Stephan van Hulst
Saloon Keeper
Posts: 9385
181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:write out the exact commands you use to compile and run it, as well as the current working folder that you run the commands from

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 38684
677
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yas,
Both of those syntaxes are still wrong.

Do this in two steps:

1) Run without mentioning assertions:
java chap6.AssertionTest

2) Then enable assertions
java -ea:chap6 chap6.AssertionTest
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!