From Pickwiki
Jump to navigationJump to search

Back to UniObjectsTest or JavaSource

  • Java source code files should have the same name as the public class they contain. So if you've copied the "TestMe" class from UniObjectsTest and pasted it into an editor, you should save it as TestMe.java
  • Make the necessary changes in TestMe.java to point it at *your* database host with a good userID and password.
  • To compile TestMe.java, you will need to have asjava.zip in your CLASSPATH. The CLASSPATH is how the JVM "finds" the classes it needs to run.
  • asjava.zip comes with any recent U2 distribution, and is usually found in /usr/unishared/uojsdk after installation. On Windows (UD 6.1 PE) it can be found in C:\IBM\UniDK\uojsdk\lib.
  • Put yourself in the same directory as TestMe.java, and try this:
        javac -classpath /path/to/asjava.zip TestMe.java
  • If you're using Windows, change all the '/' to '\' and use ; (semicolon) to separate elements of the classpath rather than : (colon)
  • If you just come back to a command prompt, that's good! List the contents of the directory and you should see not only TestMe.java, but now also a TestMe.class file.
  • To run the program, you'll need that same classpath AND IN ADDITION, the current directory, since that's where your new TestMe.class file lives:
        java -classpath /path/to/asjava.zip:. TestMe
  • Note the extra "dot" in the classpath and the LACK of an extension on TestMe. The "dot" means "this directory" and will let the JVM find your newly created TestMe.class file in order to execute it.
  • Did you get an error that says, 'Exception in thread "main" java.lang.NoClassDefFoundError: /path/to/TestMe'? If so... YOU HAVE TO ADD A "DOT" TO YOUR CLASSPATH! This is not optional!!
  • Please add to and/or correct these instructions if I've left something out or said something incorrectly.