Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: Java Native Code
|
Posted: Mar 5, 2002 2:49 PM
|
|
There are tools for compiling Java to an EXE, mentioned elsewhere and often on in this and the legacy Java Answers Forum. Just do a search.
I don't know about a tool to generate DLLs from Java.
A DLL is in some ways similar to an EXE, but by convention doesn't have a main() entry point, so it cannot be run stand-alone. (If written correctly, it can be "run" with a tool built into Windows call RunDLL, however). Also, a DLL will generally export functions for programs too call and may also contain resources -- herein lies the similarity to EXE which can also do these things.
JNI allows you to write Java code, then use a tool to generate C header files, write the C code for those headers and compile that to a DLL which can be called from Java. I suppose you could devise some scheme where you write a DLL which loads the JVM, runs a Java program that you wrote which uses some JNI to access the same or another DLL to comminicate back. Then you'd have a DLL which is using Java.
One final point about DLLs (and EXEs): it wouldn't be that feasible to simply compile a Java class to a DLL because DLLs are procedural, not object-oriented. They are just collections of functions. So the DLL would have to have some scheme to wire in the oo-aspect (like for each class Foo, it would need a newFoo() function and every non-static function would need an object parameter).
|
|