Covering the Basics
Total Page:16
File Type:pdf, Size:1020Kb
THE BASICS OF PROGRAMMING IN JAVA ON THE CAMPUS
The 3-step procedure used in java programming:
Step A: Create a source file and save it. Step B: Compile it (convert into byte code). Step C: Run it (execute it).
For Solaris operating system on campus (sitting on a windows machine)
Go to Start, go to All Programs, then go to MOSAIC XP, then go to UNIX connectivity and then click on Exceed Solaris to start the Exceed application. You will then be prompted for username (id) and password (which is the normal login procedure).After this you will be logged into Solaris system. Once you are logged into Solaris, the screen which you will get is something similar to this:
text editor
You can then follow the steps A, B, C explained below. Step A (creating a source file and saving it)
Open a text editor to write a java program. You can bring this window up by right clicking the mouse, choosing applications, then choosing text editor.
The text editor looks something like this:
Type your program and save it with a .java extension.
Step B (compiling)
Bring up a shell (sometimes called terminal) window. You can bring this window up by right clicking the mouse, choosing tools, then choosing terminal. When the window comes up, it should look like this:
Go to the directory (folder) where you saved your source file and compile the file using javac command. For example the file myprogram.java can be compiled using the command javac myprogram.java
If your command prompt appears without any error messages, then you have successfully compiled the program. A class file is automatically created by the compiler as a result of compilation operation. The class file has the same name as that of your source file but with a .class extension. For example myprogram.class is formed as a result compilation of your source file myprogram.java
Step C (Running the program)
Use the java command to run the program. For example at the command prompt where you compiled your program, type java myprogram (where myprogram is the name of class file which was created in step B)
For Solaris operating system on campus (sitting on a Solaris machine)
Follow the steps A, B and C explained above.
For Submitting the programs for grading use the command as given below cp MyProgram.java /afs/uncc.edu/usr/c/shscott/ITCS1214/section #/userid/
For Example: If you have to submit Lab1.java and your section number is 091. cp Lab1.java /afs/uncc.edu/usr/c/shscott/ITCS1214/091/l/userid/
To check if the program has been submitted: cd /afs/uncc.edu/usr/c/shscott/ITCS1214/section #//userid/ and then use ls command to check the contents of the directory.
For Submitting programs for grading using WINDOWS
Follow these steps to submit a lab using windows: Copy your java program (source code) to the clipboard Paste the java program into the directory N:\uncc.edu\usr\c\shscott\ITCS1214\section#\userid\