1. function prototype MY_API long _ stdcall GapInfo (double inTemperature, double inPressure, double inFraction [], double * outDensity, double * outSpecificHeatV, double * temperature, double * outDynamicViscosity, double * outCompressfactor, double * outKinematicViscosity); MY_API bool _ stdcall GetAPErrorInfo (long errID, char * buf, unsigned int bufLen); 2. download jna. jar, add to the reference library, create a class file copy code import com. sun. jna. library; import Com. sun. jna. native; import com. sun. jna. nativeLong; import com. sun. jna. ptr. doubleByReference; public interface MyDll extends Library {public MyDll instanceDll = (MyDll) Native. loadLibrary ("AP1700", MyDll. class); public NativeLong GapInfo (double inTemperature, double inPressure, double [] inFraction, DoubleByReference outDensity, DoubleByReference outSpecificHeatV, DoubleByReference outSpecificHeatP, Doub LeByReference outDynamicViscosity, DoubleByReference outCompressfactor, DoubleByReference outKinematicViscosity); public boolean GetAPErrorInfo (NativeLong errID, byte [] buf, int bufLen);} copy code 3. copy the code import com. sun. jna. native; import com. sun. jna. nativeLong; import com. sun. jna. ptr. doubleByReference; public class Demo {public static void main (String arg []) {System. setProperty ("jna. encoding "," GB K "); double m_temperature = 100; double m_pressure = 1; double m_HEFraction = 1; double m_N2Fraction = 0; double m_CH4Fraction = 0; double m_CO2Fraction = 0; double m_H2OFraction = 0; double [] Fraction = new double [5]; // Component Array Fraction [0] = m_HEFraction; // helium Fraction [1] = m_N2Fraction; // nitrogen Fraction [2] = m_CH4Fraction; // methane Fraction [3] = m_CO2Fraction; // CO2 Fraction [4] = m_H2OFraction; // water // The density output to the user. The specific content is specific to the specific content and the specific pressure is specific to the specific content, Viscosity, compression factor DoubleByReference Density = new DoubleByReference (); DoubleByReference SpecificHeatV = new DoubleByReference (); DoubleByReference viscosity = new DoubleByReference (); DoubleByReference DynamicViscosity = new DoubleByReference (); doubleByReference Compressfactor = new DoubleByReference (); DoubleByReference KinematicViscosity = new DoubleByReference (); NativeLong errID = MyDll. instanceDl L. gapInfo (m_temperature/* Temperature */, m_pressure/* pressure */, Fraction/* component */, Density/* Density */, SpecificHeatV/* specific capacity */, specificHeatP/* Specific compressive heat */, DynamicViscosity/* dynamic viscosity */, Compressfactor/* compression factor */, KinematicViscosity/* Motion viscosity */); if (errID. longValue ()> 0) {byte [] buf = new byte [512]; boolean B = MyDll. instanceDll. getAPErrorInfo (errID, buf, buf. length); String bufStr = Native. toString (buf); System. out. print (bufStr); System. exit (0);} System. out. printf ("density: %. 10f, \ r \ n specific volumetric specific heat: %. 10f, \ r \ n Constant Pressure specific heat: %. 10f, \ r \ n dynamic viscosity: %. 10f, \ r \ n compression factor: %. 10f, \ r \ n moving viscosity: %. 10f ", Density. getValue (), SpecificHeatV. getValue (), SpecificHeatP. getValue (), DynamicViscosity. getValue (), Compressfactor. getValue (), KinematicViscosity. getValue () ;}} copy code 4. it indicates that JNA does not need to write C code to Call DLL, which saves a lot of time. The main difficulty is type ing. The data structure and callback functions and pointer calls are not demonstrated here, it will be added later.