Md. Istiaque Shahriar isti531@gmail.com COMP346 Lab1 - How to start? Md. Istiaque Shahriar isti531@gmail.com
We will start with The following topics Basic Information Subscription to mailing list? Down load assignments Link to Electronic submission? Why do we need Java 1.2.1? How to connect to the alpha server? Work from your home pc How to modify your .cshrc file? How to move and compile YourFile.java on the alpha server? Md. Istiaque Shahriar isti531@gmail.com
Some Basic Information To subscribe https://mail.encs.concordia.ca:444/mailman/listinfo/coen346-w07 To see previous postings [downloading assignments] https://mail.encs.concordia.ca:444/mailman/private/coen346-w07/ To post a message to all the list members, send email to coen346-w07@encs.concordia.ca. Assignments are to be submitted electronically at https://eas.encs.concordia.ca/eas/authentication.jsp Md. Istiaque Shahriar isti531@gmail.com
Md. Istiaque Shahriar isti531@gmail.com Why do we need Java 1.2.1? For the purpose of learning various concurrency problems for the time being we’re stuck with the above mentioned JDK version on Linux. JVM of that version was installed in such a way so it uses so-called “green” threads, and manages them itself using the Round Robin scheduling policy (there are many policies out there, you’ll get to know what most of them are later on in the course), so the behaviour of the threads can be considered deterministic. NOTE: Java 1.2.2 is for Linux. For UNIX (ex. Solaris), Windows NT/2K/XP and Cygwin use 1.2.1. SunOS 4.x implemented "light-weight processes" or LWPs as fibers known as "green threads". Md. Istiaque Shahriar isti531@gmail.com
How to connect to the alpha server? You must have an alpha account ie. You encs account If you wish to use the alpha server from home (or anywhere outside Concordia) you should use the full name of the server - alpha.cs.concordia.ca in you ssh client. otherwise the short name alpha is enough from the Lab. Md. Istiaque Shahriar isti531@gmail.com
Md. Istiaque Shahriar isti531@gmail.com From Windows From Windows: You need a ssh tool such as one of listed below: Tera Term - should have a shortcut on your desktop under the icon “telnet”; PuTTY - a free tool that could be easily found on the net. Use the tool with the option “ssh” and the host “alpha” (or alpha.cs.concordia.ca). You may download it from here http://www.cse.concordia.ca/~hstang/teaching/cs346/useSSH.html And see the setup from here http://www.encs.concordia.ca/helpdesk/howto/ssh_tunnel.html SSH Client- This is like the one which you use from the Lab A free version is available at: http://www.encs.concordia.ca/helpdesk/howto/sftp.html Or directly http://ftp.ssh.com/pub/ssh/ and down load SSHSecureShellClient-3.2.9.exe Md. Istiaque Shahriar isti531@gmail.com
Working In Windows (If you prefer??) Write your java program using any of the convenient editors (even the text editor is a good option) Create a folder (Comp346 is preferred) in the Network U: (Unix) drive Put (save) your .java file in that folder Now Connect to the alpha server (as described) using SSH Secure Shell Client (You’ll find one on the Desktop) Now Compile and Run your program javac FileName.java Java FileName Md. Istiaque Shahriar isti531@gmail.com
Md. Istiaque Shahriar isti531@gmail.com From Linux From Linux: Use Linux OpenSSH, which is already installed on your system. To confirm this open a terminal window and type type: ssh –v To connect to “alpha” or “sunset” server type: ssh -X alpha or ssh -X sunset or ssh -X alpha.cs.concordia.ca. Md. Istiaque Shahriar isti531@gmail.com
First modify your .cshrc file List all the files in your home directory to see if there is a file under the name of .cshrc . Type : ls –a If there is no such a file then: 1. Download the file from here: http://www.cs.concordia.ca/~m_shahri/.cshrc Feel free to modify this file and if you have any problems you can always download the file again. 2. Save the file in your home directory. 3. After downloading the file open a terminal and go to your home directory. 4. Typing source .cshrc will execute the script for you. 5. Use a text editor of your choice to view the file and make changes (for example gedit, xemacs, emacs, vim, pico etc.). Md. Istiaque Shahriar isti531@gmail.com
First modify your .cshrc file If there is such a file then: 1] Open the file for editing. Use a text editor of your choice to view the file and make changes (for example gedit, xemacs, emacs, vim, pico etc.). 2] Add to the beginning of set path clause the path /pkg/java-1.2.1/bin . 3] The new set path clause should look like this: set path=( /pkg/java-1.2.1/bin /usr/ucb /usr/bin /usr/sbin /bin ...) 4] To limit the virtual memory add in a new row limit vm 300m . Now, your .cshrc file should hold the following info: set path=( /pkg/java-1.2.1/bin /usr/ucb /usr/bin /usr/sbin /bin ...) limit vm 300M 5] Save the changes and close the text editor. Md. Istiaque Shahriar isti531@gmail.com
Md. Istiaque Shahriar isti531@gmail.com The .cshrc File #cshrc January 24, 2004 # Originally written by Emil vassev # This is where your personal configuration information is held # Feel free to edit this file and change things around as much as you wish # Lines preceeded by a # are comments, a \ is used to continue commands across multiple lines set path=( /pkg/java-1.2.1/bin /site/bin /usr/bin /usr/sbin \ /bin /usr/hosts /usr/X11R6/bin /sbin /usr/lib \ ~ ~/bin ~/bin/dev ) # noclobber prevents accidently destroying existing files by redirecting input over an # already-existing file. set noclobber limit vm 300M clear # EOF Md. Istiaque Shahriar isti531@gmail.com
How to move and compile YourFile.java on the alpha server? 1] Writing your program: Use any text editor to type your java file (the one you wish to compile and run on the alpha server). 2] File Transfer: a. Use a file-transfer tool (SSH Secure File Transfer Client) to move the file to the alpha server if the file is not there. OR b. If you work under Windows on a lab PC you could simply use your “U” drive, which is your Linux drive space. There you can edit and run your java applications without having the need to move files around. (we may prefer) 3] directory comp346: If there is no directory comp346 under your home directory type: mkdir comp346 4] To Compile: javac FileName.java 5] To Execute: java FileName (no extension needed) Md. Istiaque Shahriar isti531@gmail.com
Writing your first program("Hello World“) A Checklist Work under Solaris platform connect to either “alpha” server or “Sunset” server Correct Version To write your first program, you need correct version of java: The JDK-1.2.1-A A text editor. In this example, we'll use NotePad, a simple editor included with the Windows platforms. You can easily adapt these instructions if you use a different text editor. Make sure that the file name and the class matches exactly. Md. Istiaque Shahriar isti531@gmail.com
Md. Istiaque Shahriar isti531@gmail.com The First Program /** * The HelloWorldApp class implements an application that * simply displays "Hello World!" to the standard output. */ class HelloWorldApp { public static void main(String[] args) { //Display "Hello World!" System.out.println("Hello World!"); } } Save filename as “HelloWorldApp.java” Md. Istiaque Shahriar isti531@gmail.com
Md. Istiaque Shahriar isti531@gmail.com When you're finished, the dialog box should look like this. Md. Istiaque Shahriar isti531@gmail.com
Md. Istiaque Shahriar isti531@gmail.com References www.chiark.greenend.org.uk/~sgtatham/putty/download.html man ssh www.cygwin.com http://www.cs.concordia.ca/~i_vassev/comp346_2006.html 5. http://www.encs.concordia.ca/helpdesk/howto/sftp.html Have a great Weekend Md. Istiaque Shahriar isti531@gmail.com