Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

beginners JNI problem how to create dll

 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic