Computer Science 235 :: Data Structures and Algorithms

Welcome to CS 235 Orientation


We assume that you have been introduced to the Java programming language prior to this course and that you know how to edit, compile and run a Java program. The purpose of this orientation is to help you be prepared for the course and to teach you how to compile and run a packaged Java program and to be able to submit it for passoff.

Create a CS account

This course requires that you have an account with the CS department so if you don't have one already you will need to get one. Click here to create your CS account. If you are in a CS lab and need to create an account, you should be able to login to a computer by entering guest2 as the user and password at the login screen.

Packaging a Java program

Why do we want you to learn to make packages in this class?

First so that you can better understand the Java API. If you will read and understand the Java API you will be more successfull in this course and the labs will be much easier for you. We encourage you to use the Java API as much as you can in this course; however, there will be times when we will specify that you can not use certain classes in the API. The purpose for this is so you will be able to learn about and have a better feel of what Data Structures are.

Another reason that we want you to learn how to use packages is because packages help you organize your projects.

So how do you edit, compile and run a packaged program?

If you are going to put your source code into a package, you will only need to add one line of code to the top of your file. Here is an example:
/***********************************************************
 * An example of an unpackaged hello world Java application.
 **********************************************************/ 

public class HelloWorld 
{
	public static void main(String[] parameters)
	{
		System.out.println("Hello World!");
	}
}
/***********************************************************
 * An example of a packaged hello world Java application.
 **********************************************************/ 

package cs235.hello;
			
public class HelloWorld 
{
	public static void main(String[] parameters)
	{
		System.out.println("Hello World!");
	}
}
When you are putting your code into a package you need to make sure that the directory structure and the package structure match exactly (case sensitive). When you compile a packaged Java program you need to be in the directory that contains the source code. The command to compile is:
javac -classpath rootDirectoryOfYourPackage *.java

So if C:/MyPackages/cs235/hello/*.java is the path that contains your *.java files and you are in the directory C:/MyPackages/cs235/hello/ you would type the following at the command line in order to compile the code.
javac -classpath ../.. *.java

Notice that C:/MyPackages/ is the root directory for the package.

When you run a packaged Java program from the command line you need to be in the directory that contains the class files and you type:
java -cp rootDirOfPackage dirInPackageThatContainsClassFiles.ClassName

So continuing from the the previous example you would be in the C:/MyPackages/cs235/hello/ directory and type:
java -cp ../.. cs235.hello.HelloWorld

Submitting code for CS235


You have a Subversion repository for this class. The location of your repository is:

https://seth.cs.byu.edu/cs235/netid

where netid is your route Y netid.

When you want to passoff a project for the class your code must be stored in your Subversion repository. For example, if you want to passoff the first project your .java files for the project need to be stored in:

https://seth.cs.byu.edu/cs235/netid/lab1


The following is a brief example of how to use subversion to store your hello world code.

Create a folder in your subversion repository for your hello world code.

svn mkdir -m "hello folder" https://seth/cs235/netid/lab0

Replace netid with your route-Y netid.

Subversion may ask for your username and password. Use your route-Y username and password. If the prompt shows the wrong username just hit enter.

Move your 'hello' folder out of the way.

mv hello hello-save

Checkout the 'lab0' folder from your repository:

svn checkout https://seth/cs235/netid/lab0 hello

Copy your hello world files into the hello folder.

cp hello-save/*.java hello

Add the new files to your subversion working copy.

svn add hello/*.java

Commit the changes into your subversion repository.

svn commit -m "add files"

The Subversion Tutorial gives more details about how to use your Subversion repository.

After your code is submitted, meet with a TA for pass off (not needed for the HelloWorld project).


If you have any questions or can not edit, compile, run and submit a packaged program after reading this orientation please visit a TA in the TA Office located at 1044 TMCB or go to one of the orientation meetings.