
public class Bessel
{

  // Declaration of the Native (C) function
  private native double s17acc(double x);

  static
    {
      // The runtime system executes a class's static
      // initializer when it loads the class.
      System.loadLibrary("nagCJavaInterface");
    }

  // The main program
  public static void main(String[] args)
    {
      double x, y;
      int i;

      /* Check that we've been given an argument */
      if (args.length != 1)
        {
          System.out.println("Usage: java Bessel x");
          System.out.println("       Computes Y0 Bessel function of argument x");
          System.exit(1);
        }

      // Create an object of class Bessel
      Bessel bess = new Bessel();

      /* Convert the command line argument to a double */
      x = new Double(args[0]).doubleValue();

      System.out.println();
      System.out.println("Calls of NAG Y0 Bessel function routine s17acc");
      for (i = 0; i < 10; i++)
        {
          /* Call method s17acc of object bess */
          y = bess.s17acc(x);
          System.out.println("Y0(" + x + ") is " + y);

          /* Increase x and repeat */
          x = x + 0.25;
        }
    }
}
