A Warpstock '98 Special Report
Lecturer: Terry Warren
Java Native Methods On OS/2
Combining Java And C Is Easy
The DDK toolkit contains everything you need
by
Peter Skye
ARPSTOCK
---
It's ready for Prime Time.
Java is finally being used to develop large mission critical applications that
are robust and speedy.
The latest Java compiler for OS/2 (it's from IBM, a company renowned for
quality compilers) puts Java where you want it --- as an equal with C and
C++ in the development arena.
And Terry Warren is a leading-edge Java programmer.
Let's take the Java arguments one-by-one.
Is it slow?
Not any more.
Get the latest Java release, free from IBM.
Is it portable?
It's a heck of a lot better than C.
You can write it to be fully compatible with all platforms, or put in a few
platform-dependent bells and whistles that might take a few minutes, not
days, to convert.
Is it going to be mainstream and not a niche development platform?
It's already mainstream, it's the only way to program for
Internet users, and both IBM and Microsoft are staking their futures on it.
Mr. Warren lectured thusly: You can use C code inside a Java
program.
JAVAH in the DDK reads your Java code and creates a .h C header with the
proper declarations.
Use it and linkage between the two languages is automatic.
Just remember to name your entry point Java_ClassName_MethodName.
Starting with a few Java methods, Terry showed how easy it is to link those
methods with C functions.
He used JAVAH to create the necessary C header from his Java code, and then
showed how to write C code that accepted variables from Java.
Finally, he compiled the C code into a DLL and then called it from his Java
program.
Calling C from Java and Java from C is straightforward.
Terry did the whole thing in much less than the 90 minutes allocated for his
lecture, and the audience was quite surprised at how easy it was.
My personal thanks to Mr. Warren for showing me how this is done.
For other Warpstock '98 articles see the
Warpstock '98 Article Index.
References
Terry Warren, terry@scoug.com
The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA
Copyright 1998 the Southern California OS/2 User Group. ALL RIGHTS
RESERVED.
SCOUG is a trademark of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International
Business Machines Corporation.
All other trademarks remain the property of their respective owners.
|