• Stars
    star
    809
  • Rank 55,972 (Top 2 %)
  • Language
  • License
    Other
  • Created over 6 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Example code for the book "Thinking in Java, 4th Edition"

Thinking in Java, 4th Edition: Downloading, Installing and Testing the Code

Note that this book covers Java 5/6. The recent book On Java 8 covers Java 8.

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

  1. Download the code by pressing the green button you see towards the top if this page. After pressing the button, select "Download Zip."

  2. Create a directory in which to install the code. For these instructions, we'll refer to this directory as C:\TIJ4\code.

  3. Using Winzip or some other zip utility, extract the zip file into the C:\TIJ4\code directory. When you're done, you should see several levels of directories, and in the C:\TIJ4\code directory, you'll see, among other things, subdirectories corresponding to the chapters in the book.

  4. Install the Java JDK SE5 or later from the download site at Sun. You'll also eventually want the documentation, which is available further down on that page. You may also choose to install Java SE6; the code will work with that as well. Note that the most reliable approach is to install to the default directories.

  5. Add the bin directory of your JDK to your path.

  6. Set the CLASSPATH in your computer's environment. For Windows machines, right-click on the "My Computer" icon and select "Properties." Then select the "Advanced" tab and click the "Environment Variables" button at the bottom. Under "System Variables," look to see if there's already a "CLASSPATH" variable. If there is, double click and add

    ;.;..;C:\TIJ4\code;
    

    to the end of the current entry. If there is no "CLASSPATH" variable, click the "New" button and enter

    CLASSPATH
    

    In the "Variable name" box, and

    .;..;C:\TIJ4\code;
    

    In the "Variable value" box, then click "OK". To verify that your classpath has been set, start a command prompt (see below), then enter set and look for the CLASSPATH information in the output.

  7. Install the Ant build tool by following the instructions you will find in the Ant download. Note: Ant is not required in order to compile the examples in the book. It is used to automate the process, but you can also compile each example individually (once you have the CLASSPATH set, as described above) using the javac command-line compiler that was installed when you completed the previous step (note that you may have to set the Windows PATH to point to javac.exe). To compile a file called MyProgram.java, you type javac MyProgram.java.

  8. Start a command prompt in the C:\TIJ4\code directory. To do this in Windows, press the "Start" button, then select "Run" and type "cmd" and press "OK." then type

    cd C:\TIJ4\code
    

    into the resulting command window.

  9. At this point you should be able to start a command prompt in C:\TIJ4\code and type ant build, and the build should successfully compile all the chapters up to the io chapter, where it will fail with an error message about a missing library. If you only need to work with chapters before io for now, this will suffice for awhile.

  10. You can also move into individual chapters and type ant (to compile and execute the code in that chapter) or ant build (to compile the code only).

  11. To build the entire code base, you'll need to install the additional libraries. These include:

    • XOM
    • Javassist
    • The javaws.jar library, which comes with the standard Java installation, but which you must explicitly place in your classpath (described below).
    • The Eclipse SWT library. Click on the most recent build number, then scroll down to "SWT Binary and Source" and select the file corresponding to your platform. Further details about finding the jar file are in the book under the heading "Installing SWT."

    In general, you can install the above Jar files by placing them in the jre/lib/ext directory that is part of the "Java Runtime" that will be set up when you install the Java SE5 or Java SE6 development kit. You may have to hunt around for the JRE, but it can often be found under your "Program Files" directory, under "Java."

  12. Alternatively, you can explicitly install each of the Jar files. To do this, you must add each one to your CLASSPATH, following the directions shown earlier on this page. However, you must also include the name of the Jar file in the CLASSPATH entry. For example, if you put the xom.jar file in a directory called C:\TIJ4\libraries\, then the associated CLASSPATH entry would be C:\TIJ4\libraries\xom.jar;.

  13. This code is designed to work outside of IDEs. Because packages are not introduced until later chapters, and some of the fancier IDEs like Eclipse require all code to be in packages, if you want to use the code inside those IDEs you will have to make some adjustments (however, see the Eclipse.py program in the download package for some help). Different IDEs have different requirements and it may be more trouble than it's worth while you're getting started; instead, you may want to begin with a more basic editor like JEdit.

More Repositories

1

OnJava8-Examples

Code Examples for the book "On Java 8"
Java
3,062
star
2

AtomicKotlinExamples

Examples auto-extracted from the book "Atomic Kotlin."
Java
290
star
3

ThinkingInPython

Insights, Idioms and Patterns (Python 3)
Python
103
star
4

ConcurrentPython

An intermediate-to-advanced book on Python concurrency
HTML
59
star
5

BookBuilder

Retargetable Markdown-to-epub checking and build tools for my programming books
Python
28
star
6

DataClassesAsTypes

Examples for Python Presentation: "Making Data Classes Work for You"
Python
21
star
7

HelloCookieCutter1

The most basic template, for learning about Cookiecutter
Python
18
star
8

AtomicKotlinExercises

Exercises and Solutions for the book Atomic Kotlin that haven't yet been converted to IntelliJ EDU format
Kotlin
9
star
9

PolymorphismUnbound

The code for my StrangeLoop 2022 presentation
HTML
8
star
10

SmarterTypesWithRecords

Examples for Java Presentation
Java
8
star
11

Language-Evaluation-Checklist

To compare the experience of adopting different computer programming languages
HTML
8
star
12

RethinkingObjects

Code Examples From the Pycon 2023 presentation "Rethinking Objects"
Python
7
star
13

OnJava8-Tools

Tools for building the On Java 8 book and creating the examples
Python
7
star
14

tools

My personal tools that I use across machines
Python
6
star
15

ThinkingInC

A Free Seminar Introducing the C Language
HTML
6
star
16

AtomicKotlin-hugo

Hugo Static Site sources for the book website
HTML
6
star
17

PatternMatching

Pattern Matching as a different kind of polymorphism
Python
6
star
18

TeamUp

A tool for pairing people during a workshop or seminar, so everyone eventually works with everyone.
Python
6
star
19

hello-flask-websockets

Demo program using flask-socketIO: Scroll Down for Details
HTML
6
star
20

FailingAtFailing

PDF of slides from presentation at QCon Beijing and elsewhere
5
star
21

Language-Technical-Comparison

To compare technical features of different computer programming languages
HTML
4
star
22

OnJava8-hugo

Support site for the book "On Java 8," at www.onjava8.com
CSS
4
star
23

OpenSpacesBoard

JavaScript
4
star
24

PythonClassAttributes

Exploring and understanding how class attributes work in Python
Python
4
star
25

ClarifyingConcurrency

Writing and exploring concurrency
4
star
26

MemorizeScript

A command-line utility to help actors memorize scripts
Python
4
star
27

BruceEckel-hugo

Hugo sources for "Computing Thoughts" blog
CSS
4
star
28

recipe-app-api

Django tutorial example code
Python
3
star
29

Question-Of-The-Day

For the "clearing" process
HTML
3
star
30

betools

Useful little Python tools. Docs:
Python
3
star
31

Developer-Retreat-Website

Storage for Developer Retreat site
HTML
2
star
32

KotlinOverview

A presentation about moving from Java to Kotlin
JavaScript
2
star
33

RobotExplorerPy

Robot Explorer Simulation for OO Design Example
Python
2
star
34

rust-experiments

Examples I've created while learning Rust
Rust
2
star
35

Atomizer

Python/BeautifulSoup extracts date from Word 2010 filtered HTML. Custom application, not a general tool.
Python
2
star
36

Power-of-Hybridization-Source-Code

The code referred to in the presentation
Python
2
star
37

WinterTechForum-hugo

Hugo Static Site for the Winter Tech Forum Conference
Python
2
star
38

SmarterTypesWithDataClasses

Examples for Kotlin Presentation
Kotlin
1
star
39

trustorganizations

The Trust Organization Manifesto
HTML
1
star
40

python-experiments

Python
1
star
41

TealHandbook

Hypothetical Handbook for People Working at a Teal Organization
1
star
42

SummerTechForumUnconference-hugo

Hugo Static Site for the Summer Tech Forum Conference.
Batchfile
1
star
43

slug_line

Tool to insert/update commented first line containing the file name
Python
1
star