Informatik 2 – Schmiedecke

Lab X1 – Java under Unix



Objectives: Train to read algorithms and deduce their meaning. Get used to a Unix,  or Linux,  environment and to Applets


Directly  related to:  Inf1 – X0, if you remember it….

Hand in: 

Link to your report website with Applet(s) integrated. The answers to the prep questions are a vital part of it. Also, report on the research work you have done, and include the internet links you used to get stated with Linux, vi and Applets.

Remember to show me how far you got before leaving the lab – I have to make a note of it for your grading!



1.      With our general change of perspective, we will also switch to the realm of open source operating systems, i.e. LINUX. From next week on, we will be using eclipse again, so that you will feel only little difference. But, at least for the first half of the term, you will be required to work in Linux.

2.      Today, we will be using the Java command line tools in the Linux shell. There is a variety of shells,  the so-called bash shell being the most common one. As an editor, you are asked to use vi. It is a famous, very versatile command line editor which is present on any Unix/Linux installation. So, whenever you log in on any distant Unix machine, e.g.via ssh, you can immediately start editing files using vi. That's why you should learn to use it.

Prep Work:


This lab is all about getting back into java and finding your way through Unix, so here are the most important research tasks for you. If you know the answer already, skip the question, stating your knowledge in your report.


1.      What is an Applet (or JApplet), how is it written and how is it started? (. Here is a good Sun tutorial on Applets dealing with all the basics.)

2.      Remember file reading. Bailey suggests to write a ReadStream class as analogon to the PrintStream, with a standard constructor connecting it to, and a parameterized constructor connecting it to some predefined Stream. Sketch a simplified class providing both constructors but only three methods: readWord, readLine, and isEof. What about exceptions?

3.      Use the internet to find out about


·         a concise description of the major differences between Windows and Unix / Linux

·         the Unix file system (no drives…) and its conventions

·         the most important bash commands (navigating in the directory, executing programs, reading or searching for files)

·         the JDK bash commands and how to set the classpath

·         the most important vi commands

      It is extremely useful, but voluntary, to also learn about

·         remote connections using ssh

·         remote connections from Windows machines using putty.exe


Lab work:


 Today's lab work involves very little programming, but a lot of internet research and finger exercises. Don't run away and think you can do it all at home – it may be more than you expect and assistance from others might mean a big deal.



4.      Follow the Applet tutorial and write and run the Hello World Applet from the section "Getting Started with Applets" – but do it all from the bash shell, using vi as your new editor!
Write an Applet displaying the new HTW logo and your name, and include it in your home page (or provide a testing HTML page, if your homepage is not set up yet).

If you were already familiar with Linux, you should find time to write a more interesting Applet – but remember to do it all from the bash shell ;)

5.      Modify the word frequency  program from chapter 3.3 so that it produces a graphical output in a window: a bar chart of the 20 most frequent words of a given text. Direct the ReadStream to a file, which contains a text copy (copy&paste from pdf) of the first  5 textbook chapters.
(The class ReadStream is contained in the structures package available with the textbook.)


Copyright note

Ilse Schmiedecke 2009  –  for  questions and comments: