Advertisement

[java] Report of making wrappers

Started by November 22, 2000 04:03 PM
1 comment, last by felonius 24 years, 2 months ago
Sorry about the topic title. It should read: "Report about making wrappers" Hi, As many of you know, I am an advocate for combining C++ with Java. One way to do this is to package C++ libraries so they can be used in Java. The JWindows system at www.rolemaker.dk/JWindows/ is an example of this. JWindows is a Java version of MFC and it allows user to build native Windows applications in Java. However, wrapping libraries for use in Java shares many common features no matter the library being wrapped. I have therefore written an university report (Computer Science graduate level) called "Providing Java wrapper classes for C++ class hierarchies" and turned it in today. It explains how to make such a wrapper. Using the techniques within almost any library currently only existing in C++ can be made to work in Java. I think that this may be of use to many here. Anyway, you can download the report at: (zipped Word format) http://www.rolemaker.dk/articles/Wrappers/Report.zip Please let me know what you think and whether you find it useful. Jacob Marner Edited by - felonius on 11/22/00 4:08:57 PM
Jacob Marner, M.Sc.Console Programmer, Deadline Games
You wont know this (so i''m telling you now), but I''m a critic of this sort of thing as it kill one of the founding principles of the language (cross platform), as far as I''m concerned the only valid reason for using native routines is to drive hardware. Having said that, your report is a good lowdown on how to use the native/jini methods (which is also covered by the Java tutorial @ http://web2.java.sun.com/docs/books/tutorial/native1.1/index.html ).
I''ll never really understand why you take the MFC as an example. Surly this is the worst bit of c++ to use as it is so platform dependent (isn''t it)??
Advertisement
Hi bobbin,

Thanks for you reply.

There is several reasons for using Java. One of them is, as you say, to make platform independent code. Another is to use a language that is easy to use and allows you higher productivity than say C++. This is why I am using it. I don''t care about platform indendence. I see your point - killing platform independance takes away a good feature of the language, but also platform independance has its price: speed. It prioritize speed higher than platform independance, but everybody have their own priorities.

The report only contain a short JNI tutorial (not JINI which is something else entirely), but this was only included for the sake of my professor who doesn''t know it. It is chapter 4, that is the central chapter. It describes how to use JNI to make wrappers. That is no simple feat and not something described in tutorials. It is important to realize that knowing how to use JNI is not the same as knowing how to make wrappers. I know of no other litterature on that subject.

And about MFC. I need to do Windows programming on one of my upcoming projects but want to use Java. Wrapping MFC is a good solution - the win32 API is much worse. If you look at the wrapped samples you will see that MFC has become much nicer in Java. So I took MFC as a sample because I needed it and because it is a good example of a complex C++ library. If my techniques can wrap that then my techniques should be able to wrap anything.

Cheers,
Jacob Marner
Jacob Marner, M.Sc.Console Programmer, Deadline Games

This topic is closed to new replies.

Advertisement