Home : Course Map : Chapter 5 : Java :
Using Third Party Packages
JavaTech
Course Map
Chapter 5
File/Package/Import
  Demo 1
  Demo 2
Access/Visibility
final & Constants
Static Import
Jar Files
  Demo 3
Applet Directories
3rd Party Packages
CLASSPATH
javadoc
CodingConventions
Exercises

    Supplements
Scope
Debug Techniques
Java Runtime
Class Class
JVM Instructions 2
JVM Processing
pack200

     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

We have mentioned in the introduction to this course that Java's design allows for relatively easy sharing of code.

For example, one often doesn't need to recompile subclasses even if they extend third-party classes that have been altered by their authors.

For scientific work, distributing code is important for taking advantage of other programs that provide capabilities such as graphing, math functions, numerical analysis tools, etc.

Packages are the usual way of distributing such code. A package, unless it comes in a JAR file, must be put into a subdirectory heirarchy that matches it's package name.

Also, the subdirectory, or JAR file, must be added to the CLASSPATH if it is not currently accessible.

For example, in the Chapter 5: Tech section we discuss formatting of numerical strings and refer to two freeware classes - Format and Console - from the book Core Java by C. S. Horstmann & G. Cornell.

Since the source code for these classes is available, we can put the compiler directive

  package corejava.*;

at the top of each file and put the files into a corejava directory.

For javac and java to find the files, the directory corejava must either be a subdirectory where our classes are located or the CLASSPATH must point to its location.

Note: by convention, package names are lowercase.

 

 

Latest Update: Oct. 22, 2004

            Tech
DecimalFormat
  Demo 1
  Demo 2

System.out.printf
  Demo 3
CJ Format Class
  Demo 4   Demo 5
Other Format Tools

Immutable Complex
Exercises

           Physics
Interpolation
Integration
  Demo 1
Simpson Rule
  Demo 2
Exercises

  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.