2.2. Setting up the Environment¶
Learn by Experimenting!
For each of the remaining sections in this chapter, be sure to login to Odin and type out the commands given in each part, taking notes as needed. When you are done, you will have a step-by-step outline for creating packages (both named and unnamed) in Java. Your notes and will be very useful on upcoming homework assignments and projects.
As you work through this example, you will create a package called cs1302.hello
and place Java files within that package. This section is all about getting that
environment setup on Odin.
On Odin, complete each of the following steps:
Create a directory for this tutorial called
cs1302-packages
and change into it using the following commands:mkdir cs1302-packages cd cs1302-packages
Setup the following subdirectory structure for the
cs1302.hello
package under a new subdirectory calledsrc
:cs1302-packages |--- bin |--- src |--- cs1302 |--- hello
Each subdirectory within
cs1302-packages
plays a role in the example. Here is a breakdown of the different subdirectories and their roles:bin
is the default (no-name) package directory for our compiled code (default package for compiled code);src
is the default (no-name) package directory for our source code (default package for source code);cs1302
is thecs1302
package directory; andhello
is thecs1302.hello
package directory.
If you aren’t still in the
cs1302-packages
directory, change into it and run thetree
command to make sure the directory contains all of the required subdirectories and that those subdirectories are organized correctly.
Here is a short video demonstrating these steps in case you get stuck: