Under
Borg:
No setup is required! Simply establish an SSH or Telnet* session to borg.cs.dal.ca. Login with your Borg username and password. Create your Java code in the editor of your choice. From the command line on Borg, you can use ‘vi’, ‘jove’ or ‘pico’. The following link is a tutorial for editing files on Borg:
http://borg.cs.dal.ca:8562/Editing.html
Once your java code is created and saved with a ‘.java’ extension it is ready to be compiled into byte-code. To compile your code, type:
javac
[filename.java]
where ‘filename.java’ is your sourcecode. This will create an executable java file with a ‘.class’ extension. To run your program, type:
java filename
If your code is valid, your program will run. If not, you will see a list of errors and warnings about your program.
Under
Windows:
In order to use Java under windows, you must download and install the Java Development Kit (JDK). The download page for the JDK is:
Download the package for windows (it’s about 30MB). Once your download is complete, run the executable file your just downloaded. Accept the default values suggested by the installer unless you know what you’re doing. Once the installation is completed your computer may need to be restarted.
In order to invoke the commands to compile and run java programs without having to identify where the commands are located, you must add your Java bin directory to your path. This is accomplished in different ways depending on your Operating System.
Under Windows 2000:
Under Windows NT
Under Windows 95/98
SET PATH = %PATH%; c:\jdk1.3.1_01\bin
Note that if you installed the JDK to a different location, change the above directory to reflect the change.
When your JDK is installed you are ready to start writing Java programs. Any text editor can be used to write java code. Note that Corel Wordperfect, Microsoft Word, and Wordpad ARE NOT text editors. They add formatting that is incomprehensible to the java compiler. Notepad is an appropriate editor within windows and edit will work from the windows command-line.
Once your java code is created and saved with a ‘.java’ extension it is ready to be compiled into byte-code. To compile your code, type:
javac
[filename.java]
where ‘filename.java’ is your sourcecode. This will create an executable java file with a ‘.class’ extension. To run your program, type:
java filename
If your code is valid, your program will run. If not, you will see a list of errors and warnings about your program.
What IDE should I use?
If you are coding java from home and wish to use an IDE (an Integrated Development Environment) there are several choices.
Sun’s own Java Workshop is available for free from www.sun.com. Java Workshop is available for all 32-bit Windows platforms.
IBM VisualAge for Java also has a free version. It is available from www.ibm.com. VisualAge is available for all 32-bit Windows platforms.
Borland offers Borland JBuilder. A free version is available from www.borland.com. JBuilder is available for all 32-bit Windows platforms and Unix based platforms.
CodeWarrior is a commercial application that can be purchased from their web-site (www.codewarrior.com) or from our campus computer store (www.dal.ca/~pcpc). CodeWarrior is available for all 32-bit Windows platforms, Macintosh, and Unix based platforms.
Microsoft J++ is another commercial application that can be purchased from our campus computer store (www.dal.ca/~pcpc). Please note that this application will be awkward to use as a computer science student. It will attempt to use its own classes instead of the ones from SUN (the people who created the language). J++ is available for all 32-Bit Windows platforms.
Xemacs is an X-Windows based text editor. It is available on an X-Windows terminal in the computer science building, or can be installed on a linux or Windows platform at home. It is available from http://www.xemacs.org.
An IDE has several benefits not available from most command lines.
- They provide buttons to compile and run your programs.
- They simplify debugging by allowing you to execute the program line-by-line.
- They do syntax highlighting, which colors keywords, comments, and variable names to make them easier to read.
- They can automatically indent your code to make it easier to read.
Some computer science students frown on the use of an IDE. It is wise to be familiar with coding at the command line should your IDE not be functioning or available.
Created by Dean Landry (FCS Help Desk)
Wednesday, September 05, 2001