hi all, I've just started to try my hands on jni. I started following started following sun's tutorial. i wrote the simple java file with a main function and C file with a function for printing hello. Now I'm struck coz next step was to create a DLL so that it can be loaded using loadLibrary() function of java. But I know nothing about how to create a dll from my plain C file. pls. help. regards deekasha ps -- I don't whether this is right forum to post this query... hope Marcela will take care of that.
Deekasha - In order for this to work, the code that's been written in C must be compiled into a .dll file. If you do not have a C/C++ compiler available to do this, you're pretty much stuck. ------------------ Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
Make visible what, without you, might perhaps never have been seen. - Robert Bresson
Joined: May 06, 2000
Hi Michael, Thanks for your response. I've got Microsoft Visual C++ installed at my m/c. I found the option to compile/build the file but could not find the option to make the dll? unfortunately the help is corrupted. do u or somebody else know how to make a DLL using Visual C++. pls. reply even if it seems to be spoon feeding...(I'm not a C++ person)
There should be a switch that simply directs the compiler to build a DLL. For cc and gcc it's -G. Then it's just a question of naming the outfile <whatever>.DLL. That's it. I'm not familiar with your compiler, but it shouldn't be that hard to find what flags are available at compilation time.
First of all, create a new file and then put its path to classpath. cl -Ic:\java\include -Ic:\java\include\win32 -LD HelloWorldImp.c -Fehello.dll "c:\java\include" -> This part where your java is. You better take a look at java tutorial from sun's page