NAG Logo
Numerical Algorithms Group

Using the NAG C Library with Java

This web page contains links to three examples, each in a separate zip file, showing how the NAG C Library may be called from Java. For completeness, it also contains a link to a fourth example showing how to call the NAG Fortran Library from Java, since this is referred to in the Technical Report mentioned below. (The NAG Fortran Library DLLs will need to be present on your machine to run this last example.) The information given on this page refers to calling the C Library; the corresponding Fortran Library DLL names etc. should be substituted if calling the Fortran Library.

Assuming that Java and Visual C++ are both on your PATH, you can use the batch file build.bat in each example subfolder to build and run the Java application from a command prompt. Before using build.bat, you will need to edit it such that the two environment variables JAVADIR and NAGCDIR defined within it point at your installed copies of Java and the NAG C Library.

The build files supplied here link with the import library for the stand-alone version of the NAG C Library DLL (CLDLL084Z_nag.dll); to specify the version of the DLL which uses the MKL BLAS/LAPACK instead (CLDLL084Z_mkl.dll), replace CLDLL084Z_nag.lib by CLDLL084Z_mkl.lib in the cl command in the build.bat file.

Remember also that to be able to run the Java program, the NAG C Library DLL will need to appear somewhere in your current path. For example, if the DLLs are in C:\Program Files\NAG\CL08\cldll084zl\bin, then your PATH environment variable must contain this folder. If you are using the MKL-based version of the NAG C Library (CLDLL084Z_mkl.dll), then the folder containing the MKL DLLs should also be on your path, but should appear later in the path than the bin folder for the NAG C Library DLLs, e.g.

C:\Program Files\NAG\CL08\cldll084zl\bin;C:\Program Files\NAG\CL08\
cldll084zl\MKL_ia32_8.0\bin;<rest of path>
Note that if the interface DLL (nagCJavaInterface.dll in these examples) is not in the current folder when you run the Java program, its location will also need to be added to the path.

The NAG technical report TR1_04 gives full details of how to build the necessary interfaces using Java and Visual C++. Note that this report is based on an earlier version of the NAG C Library so the build commands refer to nagc.lib instead of CLDLL084Z_nag.lib etc. Also, at Mark 8, FALSE is replaced by NAG_FALSE in the C code. In the zip files provided via the links at the top of this page, the .java and .c files have been updated to reflect these changes and the build.bat file for each example shows the correct usage for Mark 8 of the NAG C Library DLLs (or Mark 21 of the NAG Fortran Library DLLs for the EO4UCF example).

© The Numerical Algorithms Group 2008
Privacy Policy | Trademarks

© Numerical Algorithms Group

Visit NAG on the web at:

www.nag.co.uk (Europe and ROW)
www.nag.com (North America)
www.nag-j.co.jp (Japan)

http://www.nag.co.uk/numeric/CL/classocinfo/Java/README.asp