[ Help | Course Notes | Contents | Exercises ]


Solution to exercise 2

Code

PrintFuncs.java has the native method declarations.

Main.java is used to test the implementation.

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

PrintFuncs.h is the automatically generated header file.

Output

This is printed without using native code.
This is printed by a callback into Java from C++.

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     537 May 15 17:36 Main.class
-rw-rw-r--   1 mmead    students     316 May 15 17:30 Main.java
-rw-------   1 mmead    students     569 May 15 17:36 PrintFuncs.class
-rw-------   1 mmead    students     428 May 15 17:31 PrintFuncs.h
-rw-rw-r--   1 mmead    students     260 May 15 17:30 PrintFuncs.java
-rw-rw-r--   1 mmead    students     534 May 15 17:36 PrintFuncsImp.cpp
-rwx------   1 mmead    students     277 May 15 17:31 RunSolaris
-rwx------   1 mmead    students    5368 May 15 17:36 libPrintFuncsImp.so

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