Running and Compiling JNI on NT

  • The Setup
    1. Go to an NT machine
    2. Use the latest JDK for all you Java Compiling and Running needs. In the Baird NT lab, you will want to add the JDK to your path:
      	C:\TEMP>SET PATH=S:\APPS\JDK1.1.7B\BIN;%PATH%
      
    3. Get the latest VRM client library (NTCLIENT.DLL)
    4. Get the Agent.java and Ncomm.java files
    5. Run VRM Server on the appropriate port

  • Compiling the Super Classes
    1. Set the Server and server port in Ncomm.java:
      	connect("dash", 2112);
      
    2. Compile Ncomm.java (make sure you are using latest JDK):
      	C:\TEMP\> javac Ncomm.java
      
    3. Compile Agent.java:
      	C:\TEMP\> javac Agent.java
      
  • Writing the Code
    • Here's an example of how to write code to use the JNI:
      class MyClass
      {
      	Ncomm	comm;
      
      	public static void main(String[] args)
      	{
      		Ncomm comm = new Ncomm();
      		Agent b = new Agent();
      		b.create(comm);
      
      		b.move_right(comm);
      		b.move_forward(comm);
      		b.move_back(comm);
      		...
              }
      }
      

  • Compiling the Code
    • Here how to compile the code you just wrote:
      	C:\TEMP\> javac mycode.java
      

  • Running the Code
    1. Make sure NTclient.DLL is in current directory
    2. Make sure Ncomm.class and Agent.class are in the current directory
    3. Make sure you are using the latest JDK
    4. Run the code you wrote:
      	C:\TEMP\> java MyClass
      

<< Back to Course View: Winter 1999