Frequently Asked Questions
Thanks go to Lane Schwartz for maintaining the Fall 2007 CSci 1902
FAQ; some text here is adapted from his answers.
ITLabs computer information
How do I activate Eclipse in my ITLabs account?
To use Eclipse in your ITLabs account, you will need to add the
Emacs 3.3 module to your account. You can check whether this module
is currently loaded with the following command in a terminal session:
module list
This will list the modules available. If java/eclipse/3.3 appears in
the list, then your account should be good to go.
If there is a java/eclipse entry, but it is the wrong version
(e.g. java/eclipse/3.2), you will need to remove it. Run the
following two commands:
module rm java/eclipse
module initrm java/eclipse
Once you have removed the old java/eclipse (or if there was no
java/eclipse entry in your module list to begin with), run the
following commands to load Eclipse:
module add java/eclipse/3.3
module initadd java/eclipse/3.3
The first command (module add) loads the module into your current
terminal session. The second command (module initadd) adds the module
to your ~/.cshrc file, so that it is available next time you log in or
start a terminal.
Programming assignments
How do I submit my programming assignment?
To submit your assignment, use the package target of the provided Ant
build file to create a tar archive of your project, and submit the
resulting archive (a .tgz file) via the web-based submit system.
Once you have submitted your assignment, you will see a submission
receipt listing all the files submitted (the contents of the
archive). Review this to make sure it contains all required files.
You are responsible for making sure that your submissions contain all
required files. Failure to do so may result in receiving a grade of 0
for the assignment.
You will also receive a submission receipt via e-mail to your ITLabs
e-mail account. See the ITLabs e-mail page for information on
accessing this account. Alternatively, you can forward your e-mail
from the ITLabs account to another account you check more often
(i.e. your university e-mail) by creating a file in your home
directory called .forward containing a single line with the e-mail
address you want your mail forwarded to. You can do this with any
standard UNIX text editor, such as emacs, vi, or pico.
General Java information
Where can I find Java documentation?
The Java 5.0 API reference contains documentation for all of the
standard classes and packages available in Java 1.5. We recommend
bookmarking this page, as you will need to refer to it frequently
throughout this course.
What version of Java are we using?
We will be using and teaching Java 5.0/1.5. In some cases you may be
using Java 6 either in the lab or on a home computer; this is fine.
However, we will not be teaching features specific to Java 6, and your
assignment solutions must be able to compile and run in Java 1.5.
What's Java 5? Java 6? Java 1.6?
Starting with Java 1.5, Sun began changing the version numbering
scheme of Java. "Java 5.0" and "Java 1.5" are the same thing. 1.5 is
the internal version number, and 5.0 is usually used for marketing
purposes. With 1.6/6.0, the 6 seems to be seen more often.
Java/Eclipse Problems
Strange errors when running programs or unit tests in Eclipse
If your Eclipse workspace is configured to use the Java runtime for a
platform other than the one you're currently running on (e.g. it's
trying to use a Linux Java runtime on a Solaris computer), you'll get
cryptic errors on the console when you try to run Java applications or
unit tests from Eclipse. An example:
/soft/java/Linux_x64/jdk1.6.0_02/bin/java: syntax error at line 1: `('unexpected
Eclipse keeps trying to use the last Java your workspace was
configured to use, and does not automatically detect when you switch
platforms. If you're using both Linux and Solaris ITLabs computers to
work on assignments, you will probably see this problem. The solution
is to maintain configurations for 2 (or 3) JRE's, and switch between
them when you change platforms. The ``Java/Installed JRE's'' panel in
the preferences dialog (``Window -> Preferences'' in Eclipse) allows
you to manage the Java runtimes you have configured, and select one to
use for the current session.
To add a new JRE, click the ``Add...'' button in this dialog. Give
your JRE a name (such as ``SunOS Java 5''). In the ``JRE Home
Directory'' text box, type the correct directory for your platform,
and click OK. The Java directories are:
- SunOS/Solaris: /soft/java/SunOS/jdk1.5.0_09
- Linux: /soft/java/Linux/jdk1.5.0_09
- Linux (64-bit): /soft/java/Linux_x64/jdk1.5.0_09
Lastly, make sure that the correct JRE for your platform is selected
as the default JRE (it will be checked in the list), and click OK.
Once you've set up the JRE's for the different platforms you'll be
working on, all you'll need to do when you switch platforms is go to
the JRE's configuration panel, check the one you need, and click OK.
Ant
What is Ant?
Ant is a tool for managing software compilation, specifically designed
to meet the needs of building Java programs. If you've ever used the
UNIX make tool, Ant is similar, except that it is oriented towards
Java.
You will not need to learn how to write Ant build control files for
this class. You will not need to learn anything about Ant other than
how to use it with the build files we provide to build and test
homework assignments.
But we have Eclipse. Why use Ant?
* Some people like to use text editors (such as Emacs or VIM) and
command-line tools for software development. Ant is more suited to
Java development than make, and thus provides an effective tool for
such people to build their Java programs.
* It is infeasible to grade homework assignments by loading each one
in Eclipse to run and examine it. Eclipse is a powerful tool, but
its resource requirements and the inherent efficiency limitations
of graphical environments reduce its effectiveness for dealing with
many homework assignments in succession. Using Ant allows us to
grade assignments quickly and efficiently by running everything
from the command line.
How do I configure Ant in my ITLabs account?
Ant is available as the java/ant module on ITLabs (and CS) systems.
There is one catch that can cause problems running Ant on ITLabs
Linux (but not Solaris) machines. The Linux installations used on
ITLabs machines include a version of Ant, but it is not the latest
version and it does not contain support for some features we will be
using. Therefore, it is important to make sure that you are using Ant
from the module, and not Ant from the local system. To see which Ant
you are using, run the following:
which ant
If it says /soft/java/ant-1.7.0/bin/ant, (or something else in /soft),
then you have the right Ant. If it says /usr/bin/ant, then you need a
different Ant. Unfortunately, the standard module initadd command
does not work for this, as it will add the Ant module after the
system-installed Ant. Therefore, you need to edit your ~/.cshrc
file. Open it in your favorite editor (if you are new to UNIX and
don't know either vi or emacs, pico is a simple editor which will get
the job done with a minimal learning curve; alternatively, if you are
at a graphical terminal, use gedit):
pico ~/.cshrc
Go down through the file, and you should find a line or set of lines
beginning with the command module load. In the first of these lines,
add java/ant before system. Therefore, you should have a line
something like this:
module load soft/gcc java java/ant perl <...> system <...>
The <...> are replaced with potentially some module names. The
important thing is that java/ant appears before any occurrence of
system.
Once you have made the changes, save (or "write") the file, and close
your editor. Then close the terminal, and open a new one. When you
type which ant, you should see the correct output.
How do I run Ant?
Ant is run with the ant command. It takes a variety of arguments; the
most important one is the target, which is a one-word instruction of
what Ant is to do. Targets are defined in the Ant build file (called
build.xml). For example, to run the build target, run the following:
ant build
The following are some of the targets that will be available in the
build files we provide:
build
- Compile the program.
run
- Run the program. There may be some more options controlling
this target's behavior; if there are, they will be described in
the assignment description.
test
- Run the unit tests (or other tests) associated with the
assignment. Summary output is displayed, and the detailed results
of specific tests will be written to
TEST-<testclassname>.txt
files in the current directory.
clean
- Remove generated files (
.class files compiled from the Java
source code, test output files, etc.). This target will not
delete any of your code, so long as it is in .java files, nor will
it delete other arbitrary files in your directory.
To be safe, however, it is not unwise to make a backup copy of
your assignment before you try this target for the first time for
an assignment. It is possible (although unlikely) that you may
inadvertently create a file which the clean target thinks it needs
to delete.
The purpose of clean is to reset the project to a clean status
from which then entire project can be recompiled or distributed
without unnecessary files (which would just be rebuilt anyway).
package
- Generate a package for submitting the assignment. If the
assignment is Homework 1, the generated file will be called
hw1.tgz.
Working from home
While we cannot provide support for student's computer configurations
or working on systems other than the ITLabs computers, you may
certainly work on your own computer when working on homework
assignments. The answers in this section should help you do so.
How do I get Eclipse?
You can get Eclipse by downloading it from the Eclipse web page.
Either the "IDE for Java Developers" or the "Classic" version should
work.
Note that you will need a Java runtime environment to run Eclipse.
You can get one from Sun's Java pages.
How do I use Ant?
It is possible to run Ant on your personal computer. If you have
Eclipse, it may include a version of Ant. Otherwise, download it from
the Ant web site. You'll need both a Java run time (see previous
question) and a full Java development kit (which includes a run
time) to use this. The Java development kit can be downloaded from
Sun's Java pages.
Alternatively, many Linux systems come with Ant either preinstalled or
readily available. On Debian-based (probably including Ubuntu)
systems, install the ant and ant-optional packages.
Note that we cannot provide support for getting Ant working on your
system. If you have problems, try posting to the forum and seeing if
anyone can help.
|