@Peter Lawrey Dr. Java is an IDE, stdlib is one of the jars I downloaded and am trying to import into my program. I've attempted to manually add these jars to my classpath with no success. – Michael Gruber Sep 18 '12 at 17:26. This site requires JavaScript to be enabled. DrJava is an integrated Java development environment that supports interactive evaluation of expressions. It is available for free, and it is available under an open source license (GPL).
Standard libraries.
Below is a table of the input and output libraries that we use throughoutthe textbook and beyond.§ | PROGRAM | DESCRIPTION / JAVADOC |
---|---|---|
1.5 | StdIn.java | read numbers and text from standard input |
1.5 | StdOut.java | write numbers and text to standard output |
1.5 | StdDraw.java | draw geometric shapes in a window |
1.5 | StdAudio.java | create, play, and manipulate sound |
2.2 | StdRandom.java | generate random numbers |
2.2 | StdStats.java | compute statistics |
2.2 | StdArrayIO.java | read and write 1D and 2D arrays |
3.1 | In.java | read numbers and text from files and URLs |
3.1 | Out.java | write numbers and text to files |
3.1 | Draw.java | draw geometric shapes |
3.1 | DrawListener.java | support keyboard and mouse events in Draw |
3.1 | Picture.java | process color images |
3.1 | GrayscalePicture.java | process grayscale images |
3.2 | Stopwatch.java | measure running time (wall clock) |
3.2 | StopwatchCPU.java | measure running time (CPU) |
– | BinaryStdIn.java | read bits from standard input |
– | BinaryStdOut.java | write bits to standard output |
– | BinaryIn.java | read bits from files and URLs |
– | BinaryOut.java | write bits to files |
Using the standard libraries.
The file stdlib.jar bundles together all of ourstandard libraries into one file.To access the libraries, you must addstdlib.jar
to your Java classpath.There are many ways to do so (and many opportunities to make mistakes).Here are the two recommended ways:- Use the javac-introcs and java-introcs commands.If you followed our installation instructions forMac OS X,Windows, orLinux,the commands
javac-introcs
andjava-introcs
are availablefrom the command line (with OS X or Linux) or Git Bash (with Windows). - Use our IntelliJ project folders.If you use IntelliJ, the project folders we supply are preconfigured to include
stdlib.jar
in the classpath.
- Use the -classpath command-line option.Put stdlib.jar in the same directory asthe program you are writing (but do not unjar it).Then, compile and execute as follows:The -classpath option tells Java which directoriesto search for for .java and .class filesThe . refers to the current directory (which contains MyProgram.java and MyProgram.class).The stdlib.jar refers to the
jar
file containingour standard libraries.On OS X, the : separatesdirectories in the classpath; on Windows the ;separates directories. - Current directory.Perhaps the simplest (but definitely not the sanest) way to use the standard librariesto download stdlib.jar and unjar itin your current working directory.Alternatively, you can download the individual .java files you need(such as StdIn.java)and put them in the same directory as the program you are writing.Then, compile and execute as usual.This approach has the drawback that you need a copy of each .javafile you need in each directory where you need it.
- Use the CLASSPATH environment variable.You can set your system CLASSPATH environment variable to contain stdlib.jar.We do not recommend this approach because the CLASSPATH variable may be usedby other applications.
- Configure your IDE.You can configure your IDE to include stdlib.jar in the classpath.
- IntelliJ: select File → Project Structure → Libraries.
- Eclipse: select Project → Properties → Java Build Path → Libaries → Add External JARs.
- DrJava: select Preferences → Extra Classpath → Add.
- Windows Command Prompt: select Start → Computer → System Properties → Advanced → Environment Variables → User Variables → CLASSPATH.
Standard input and standard output.
StdIn.java andStdOut.java are librariesfor reading in numbers and text from standard input and printing outnumbers and text to standard output.Our versions have a simpler interface than the corresponding Java ones(and provide a few tecnical improvements).Average.java reads in a sequence of real numbers from standard input and prints theiraverage on standard output.In.java andOut.java are object-orientedversions that support multiple input and output streams,including reading from a file or URL and writing to a file.Wget.java reads in data from the URL specified on the command line and save itin a file with the same name.Binary standard input and standard output.
BinaryStdIn.java andBinaryStdOut.java are the analogsfor binary data.Copy.java reads a binary file fromstandard input and writes it to standard output.Standard drawing.
Download Java For Mac
StdDraw.java is an easy-to-use libraryfor drawing geometric shapes, such as points, lines, and circles.RightTriangle.javadraws a right triangle and a circumscribing circle.% java RightTriangle
BouncingBall.javaillustrates how to produce an animation using standard drawing.