Starting from:

$25

CSCI1302 - Programming Project 1  - Linux and Java warm-up - Solved

In this project, you will create, compile and run a simple Java program on our Linux server.  


      Design and implement a Java class called User, in which the main method prints out on standard output a single line of text of the form:

I am your_username on operating_system_type 

For example, for user smith, the output of your program should be exactly like this:

I am smith on Linux 

Your program must not output anything else.   

You should use either emacs or vi (both are available on odin) to create the source code for your class.  Also, you should use the javac and java commands to compile and run your program, respectively.

     The part of the required output line after “I am ” should be created using the values returned from calls to the static methods getUserName() and getOSName(), provided by the UserIdentifier class. These methods are declared as: public static String getUserName() public static String getOSName() 

Your program should simply print the string  ”I am ”  concatenated  with the values returned by  the getUserName  and getOSName  methods with “ on “ in between. 

     The UserIdentifier class is included in a jar file, called ident.jar, which is available in directory /home/myid/kkochut/classes on odin (the directory and the jar file are publicly readable).  You will have to define the CLASSPATH environment variable or use an appropriate option when compiling and running your program, in order to include access to ident.jar.  If you prefer, you can copy this jar file into your own file space.


More products