File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assertions ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assertions ?" Watch "Assertions ?" New topic
Author

Assertions ?

Shafkat Talli
Ranch Hand

Joined: Aug 01, 2003
Posts: 30
Im new to java 1.4 and assertions, my study guide for da exam says,
----------------------
To compile a program with assertions, you write:

>javac -source 1.4 <filename>.java
----------------
This is what i get if i try to compile my source file:
D:\MY CAVE\Work\Java Certification>javac -source 1.4 Test.java
javac: invalid flag: -source
use: javac [-g][-O][-debug][-depend][-nowarn][-verbose][-classpath path][-nowrit
e][-deprecation][-d dir][-J<runtime flag>] file.java...
-----------
DONT UNDERSTAND, IM SOOOOOO CONFUSED ((

If i run the java -version from command prompt, one can c that i have java 1.4:
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)


---------------------------<br />Shafkat Talli<br />SCJP 1.4, August 2003.
skip coon
Greenhorn

Joined: Feb 01, 2003
Posts: 13
hey there,
An easy way to double check what options your javac has just type javac in your shell. A list of options will then be displayed:
I am running:
java version "1.4.1_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_03-b02)
Java HotSpot(TM) Client VM (build 1.4.1_03-b02, mixed mode)
ie:
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-help Print a synopsis of standard options

I hope this helps.
scoon
Shafkat Talli
Ranch Hand

Joined: Aug 01, 2003
Posts: 30
I still dont understand. The study guide says that java 1.4 covers assertions, and i try to use the java syntax ive written in my first post, but it wont compile. And when i write java in my command window, it doesnt support the -source option, why is that ? and when i dont got this option, how can i compile source with assertions in it ? I c that u have java version 1.4.1_03 while i have 1.4.1_01, if thats the case, then the study guide should say that i have to use java version 1.4.1_03....still confused
D:\MY CAVE\Work\Java Certification>java
Usage: java [-options] class [args...]
(to execute a class)
or java -jar [-options] 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 -classpath <directories and zip/jar files separated by ;>
set search path for application classes and resources
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-showversion print product version and continue
-? -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
[ August 10, 2003: Message edited by: Shafkat Talli ]
skip coon
Greenhorn

Joined: Feb 01, 2003
Posts: 13
Hey there,

In your reply you used java in the shell window, not javac. try that and see what is displayed.

scoon
Shafkat Talli
Ranch Hand

Joined: Aug 01, 2003
Posts: 30
This is what i get if i try to compile my source file:
D:\MY CAVE\Work\Java Certification>javac -source 1.4 Test.java
javac: invalid flag: -source
use: javac [-g][-O][-debug][-depend][-nowarn][-verbose][-classpath path][-nowrit
e][-deprecation][-d dir][-J<runtime flag>] file.java...
skip coon
Greenhorn

Joined: Feb 01, 2003
Posts: 13
Hey there,
I know that is what you get when you try to run javac with the '-source' tag. I just wanted to see the output of your shell when you just type javac. Like so:
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-help Print a synopsis of standard options
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assertions ?