- UNIX
% cc -G HelloWorld.c HelloWorldImp.c -o libhello.so
Note: You may need to use the-Iflag to indicate to the compiler where to find the various header files. For examplecc -G -I$JAVAHOME/include -I$JAVAHOME/include/solaris HelloWorld.c HelloWorldImp.c -o libhello.sowhere$JAVAHOMEis the directory where you installed the Java release. The C compiler will create a filelibhello.soin the current directory.
- DOS shell (Windows 95/NT)
C:\> cl HelloWorld.c HelloWorldImp.c -Fehello.dll -MD -LD javai.libNote: You must have Microsoft Visual C++ Version 2.x to compile and link DLLs (Dynamic Link Libraries).Note:
javai.libmust be the last argument to the C compiler.Note: To inform the compiler of the location of the Java C header files, add
%JAVAHOME%\includeto the environment variableINCLUDE:C:\> set INCLUDE=%JAVAHOME%\include;%INCLUDE%Note: To inform the linker of the location of the Java libraries, add
%JAVAHOME%\libto the environment variableLIB:C:\> set LIB=%JAVAHOME%\lib;%LIB%