1 / 4

Packages, javac, java, javadoc

Packages, javac, java, javadoc. In moderately big programs packages are essential Can’t easily live in a directory with 50 .java files Can’t easily co-exist in such a directory Harder to use tools like Make and Ant

ray
Download Presentation

Packages, javac, java, javadoc

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Packages, javac, java, javadoc • In moderately big programs packages are essential • Can’t easily live in a directory with 50 .java files • Can’t easily co-exist in such a directory • Harder to use tools like Make and Ant • Java packages correspond semantically to modules (related classes) and syntactically to a directory structure • Class names correspond to file names • Package names correspond to directories • Each of javac, java, javadoc is slightly different with packages • File system vs. compiler vs. runtime

  2. CLASSPATH and related concepts • The default CLASSPATH is . current directory • Works fine with default/unnamed packages • Will not work with named packages • Set CLASSPATH to directory in which packages live also include current dir • setenv CLASSPATH "~ola:." • setenv CLASSPATH "`pwd`:." • On windows machines change environment variable • 'ls' should show, e.g., elan (which has parser, instruction, and so on, see the elan example)

  3. More package details • To compile • Can cd into directory and type javac *.java • Can also type javac elan/*.java from one level up • If CLASSPATH isn't set, the second won't work • To run • java elan.parser.ElanParser will work, you must specify the "real" name of the class being used. • Reading files requires full-paths or run from directory in which file lives • To document • http://java.sun.com/j2se/javadoc/faq.html • Don't need to use –sourcepath, but can • javadoc –d doc elan elan.parser elan.instruction …

  4. Elan parsing • Packages separate concepts and concerns • expression is just for standard infix expressions • Like the BNF example from jelan/simple • instruction is for programming constructs, e.g., repeat • See Instruction, RepeatInstruction, and SILInstruction • Each sub-package must import other packages • Problem? Depends on point-of-view • Adding a new language feature, e.g., IF statement • IfToken added in elan/parser/token • IfParser added in elan/parser • If instruction added in elan/instruction, returned by parser • If added to instructions.prop

More Related