aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes beginners JNI problem how to create dll Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "beginners JNI problem how to create dll" Watch "beginners JNI problem how to create dll" New topic
Author

beginners JNI problem how to create dll

deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
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.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

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
deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
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)

regards
deeksha

Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

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.
G�k�e Mutlu
Greenhorn

Joined: Dec 01, 2003
Posts: 1
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: beginners JNI problem how to create dll