[ Help | Course Notes | Contents | Exercises ]


Solution to exercise 1

Code

MathFuncs.java has the native method declarations.

Main.java is used to test the implementation.

MathFuncsImp.cpp implements the native methods in C++.

MathFuncs.h is the automatically generated header file.

Output

Area of circle with radius 2 is 12.566370614

Compilation and execution

RunNT These commands build the project and execute the program under Windows NT.

RunSolaris These commands build the project and execute the program under Solaris.

RunLinux These commands build the project and execute the program under Linux.

On sirius, you'll end up with something like this in your directory:

-rw-------   1 mmead    students     826 May 14 11:18 Main.class
-rw-rw-r--   1 mmead    students     306 May 14 11:10 Main.java
-rw-------   1 mmead    students     424 May 14 11:18 MathFuncs.class
-rw-------   1 mmead    students     417 May 14 11:11 MathFuncs.h
-rw-rw-r--   1 mmead    students     191 May 14 11:11 MathFuncs.java
-rw-rw-r--   1 mmead    students     303 May 14 11:11 MathFuncsImp.cpp
-rwxr--r--   1 mmead    students     273 May 14 11:14 RunSolaris
-rwx------   1 mmead    students    4720 May 14 11:18 libMathFuncsImp.so

Copyright © 1998 Sergio Antoy. All Rights Reserved
February 99, version 020199