Home : Course Map : Chapter 22 :
JNI Demo - Support Files
JavaTech
Course Map
Chapter 22

Introduction
Java Code
C++ Code
Support Files
Resources

Exercises

     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

The following support files build and run the JNI demos.

 

build.bat

@rem Build the jni22 example on Windows

@rem create the build/classes directory
mkdir build
mkdir build\classes

@rem Compile the Java
javac -classpath build/classes -d build/classes src/javatech/jni22/*.java

@rem Run javah to generate the header file
javah -classpath build/classes -d build/headers -jni javatech.jni22.JNIHelloWorld
javah -classpath build/classes -d build/headers -jni javatech.jni22.StringExample
javah -classpath build/classes -d build/headers -jni javatech.jni22.ArrayExample
javah -classpath build/classes -d build/headers -jni javatech.jni22.JNIDemo

@rem Compile the C++ native implementation codes. This requires Microsoft
@rem Visual C++ 6.0.
mkdir build\objs
cl -c -Ibuild\headers -I%JAVA_HOME%\include -I%JAVA_HOME%\include\win32 -Fobuild\objs\NativeHelloWorld.obj src\javatech\jni22\NativeHelloWorld.cpp
cl -c -Ibuild\headers -I%JAVA_HOME%\include -I%JAVA_HOME%\include\win32 -Fobuild\objs\NativeString.obj src\javatech\jni22\NativeString.cpp
cl -c -Ibuild\headers -I%JAVA_HOME%\include -I%JAVA_HOME%\include\win32 -Fobuild\objs\NativeArray.obj src\javatech\jni22\NativeArray.cpp
cl -c -Ibuild\headers -I%JAVA_HOME%\include -I%JAVA_HOME%\include\win32 -Fobuild\objs\NativeJNIDemo.obj src\javatech\jni22\NativeJNIDemo.cpp

@rem Create the shared library DLLs
link -dll build\objs\NativeHelloWorld.obj -out:build\NativeHelloWorld.dll
link -dll build\objs\NativeString.obj -out:build\NativeString.dll
link -dll build\objs\NativeArray.obj -out:build\NativeArray.dll
link -dll build\objs\NativeJNIDemo.obj -out:build\NativeJNIDemo.dll

clean.bat
@rem clean up all generated and compiled files for the javatech-22 directory
rmdir/s/q build
run.demo.bat
@rem Run the jni22 JNIDemo example on Windows
java -classpath build/classes -Djava.library.path=build javatech.jni22.JNIDemo
run.hello.bat

@rem Run the jni22 example on Windows

java -classpath build/classes -Djava.library.path=build javatech.jni22.JNIHelloWorld

@rem alternatively, we can add to PATH to include the location of the shared
@rem library, NativeHelloWorld.dll, that must be found at runtime.
@rem set PATH=build;%PATH%
@rem java -classpath build/classes javatech.jni22.JNIHelloWorld

run.string.bat
@rem Run the jni22 StringExample on Windows
java -classpath build/classes -Djava.library.path=build javatech.jni22.StringExample
run.array.bat
@rem Run the jni22 ArrayExample on Windows
java -classpath build/classes -Djava.library.path=build javatech.jni22.ArrayExample

 

Most recent update: Oct. 14, 2005

  
  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.