Lab-0

Classpath, Packages,
Jar Files, Reflection, JDBC

Perform the following tasks:

  1. You are given the class file Bundle1.class. It is known that this class has a default constructor and a method called operate that takes two int's and return an int. Write the class Use1.java that acts as a client of Bundle1; specifically, it passes 2 and 3 to operate and captures and outputs the return.
    Hint: Yes, this is a trivial question! It simply sets the stage for the rest of the questions.


  2. Write the class Use2.java that acts as a client of Bundle2.class. This is similar to (1) above but you now need to examine the resulting compile-time error and figure out a solution; i.e. make the client work.


  3. Write the class Use3.java that acts as a client of Bundle3.class which is given in the jar file bun.jar. This is similar to (1) but you now need to use the jar command, with the correct command-line options, to verify that it does indeed contain a file named Bundle3.class. Can you extract the file out of the jar? Where will you store it? Could you have made the client work without extracting?
    Hint: You may want to read jar.txt in RD under "java".


  4. Write the class Use4.java that acts as a client of Bundle4.class. This is similar to (1) above but you now need to examine the resulting compile-time error and figure out a solution; i.e. make the client work.
    Hint: The method name is clearly not operate! See the reflection pseudocode in RD under "java".


  5. The jar file axis.jar contains an app named tcpmon (recall that an app is something that you launch, not invoke). Your job is simply to run this app. No coding is involved here, just determine the correct command to launch this app.

The following additional tasks are optional:

  1. The file Northwind.mdb is a Microsoft Access database. It contains a table named Products. Create a SQL query within MS-Access to determines the products whose unit price is over $100. Create a second query to determines if any Beverages have a unit price over $100. Note that each product has a category and this one-to-many relation is manifested by having each product hold a category ID that points to the Categories table.


  2. Redo the previous question programmatically; i.e. embed the query in a Java app rather than build it within Access.
    Hint: See the MS-Access jdbc pseudocode in RD under "java".


  3. Your job is to export the contents of the Products table of the previous question from its Microsoft Access database (running under Windows on your PC) to an IBM DB2 database (running under Linux/Unix on red). How will you accomplish this task?
    Hint: See the DB2 jdbc pseudocode in RD under "java".