|
[ Help
| Course Notes
| Contents
| Exercises
]
|
|
Solution to exercise 3 |
JavaFields.java has the native method declaration and four fields that the native method will access.Main.java is used to test the implementation.
JavaFieldsImp.cpp implements the native method in C++ that will access the Java fields.
JavaFields.h is the automatically generated header file.
From native code: public int i = 1 public float f = 2.450000 static public int si = 3 private int pi = 5 After native call: public int i = 100 public float f = 123.45 static public int si = 200 private int pi = 300
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 615 May 17 14:42 JavaFields.class -rw------- 1 mmead students 399 May 17 14:20 JavaFields.h -rw-rw-r-- 1 mmead students 307 May 17 14:18 JavaFields.java -rw-rw-r-- 1 mmead students 1520 May 17 14:41 JavaFieldsImp.cpp -rw------- 1 mmead students 1013 May 17 14:42 Main.class -rw-rw-r-- 1 mmead students 471 May 17 14:18 Main.java -rwx------ 1 mmead students 277 May 17 14:20 RunSolaris -rwx------ 1 mmead students 7532 May 17 14:42 libJavaFieldsImp.so
|
Copyright © 1998
Sergio Antoy.
All Rights Reserved February 99, version 020199 |