Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with a simple DLL 2

Status
Not open for further replies.

cadbilbao

Programmer
Apr 9, 2001
233
ES
Hello!!

I compile this piece of code succesfully, but when I call it, nothing appears:

[red]
#include <stdio.h>
#include &quot;HelloWorld.h&quot; // this header file was generated by javah

void function(char *infile) {
printf(&quot;\n%s\n&quot;,infile);
}

JNIEXPORT void JNICALL Java_HelloWorld_displayMessage(JNIEnv *env, jobject obj) {
function(&quot;Hello World!&quot;);
}
[/red]

On the other hand, &quot;Hello World&quot; appears with this other:

[red]
#include <stdio.h>
#include &quot;HelloWorld.h&quot; // this header file was generated by javah
JNIEXPORT void JNICALL Java_HelloWorld_displayMessage(JNIEnv *env, jobject obj) {
printf(&quot;\nHello World!\n&quot;);
}
[/red]

Any suggestion?
 
You can call JNI only from java progs, not from C++ programs. Java you can call from C++ only using COM. John Fill
1c.bmp


ivfmd@mail.md
 
Actually, you can call Java from C++ using JNI. It isn't pretty, JNI was ment to be from Java to C++, but it does work. Sadly there isn't a lot of documentation on this.

As for why the first code fragment didn't work, I'm not sure. I'm about 99% sure I have done this very thing operation before. I'll have to go check.
 
Hi everybody,
i'm using JNIEnv to display a context menu calling this function from a java application and it's working pretty well but need some more documentation about JNIEnv. Where do i find it?
 
ArkM, do you see, my post is written in 2001. I don't believe COM is the single way Java to be called from C++. By the way, the jeecas com bridge is not supported anymore. So, better now is to use CORBA, SOAP, HTTP, TCP... Java web start also provides some access to Java from native languages as C++ and VisualStudioVB/OfficeVBA.

Ion Filipski
1c.bmp
 
Sorry, Ion: I haven't noticed that it was in 2001. In 2000 we used JNI to start Java app in C++ msg processing server.
Truth to tell, I think that C++ only was the best answer to a problem...
 
Great ArkM, I tried that yeasterday. It works. That documentation is old and is for jdk1.1, but works with some small changes.

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top