This content has been marked as final. Show 11 replies
Those headers don't exist in Windows. The functions they define don't exist in Windows. You will have to adjust your C code so that it calls functions that do exist in Windows, and include the corresponding header files.
None of this has anything to do with Java, or these forums, or this site.
I wouldn't agree. The first example is from Oracle Sun Tutorial about JNI. So this example is wrong? (at least for Windows?).
Edited by: 935411 on 2012-05-19 04:32
If it was correct it would compile. As it doesn't compile, it isn't correct. There is no mmap() function in Windows. There is a similar function with a different name, but that's not a Java question. None of it is.
Hmm, perhaps you're right. But I think this forum is attended by people who did such things. Because this is also a question of running java program. If I don't create proper dll, I won't run java program in windows either. So by using JNI in windows one has to learn how to create dll. If it's not the proper forum, perhaps, You could direct me to a proper one?.
Edited by: 935411 on 2012-05-19 08:08
The question of whether or not a Windows C SDK contains mmap.h and a linkable mmap() function has nothing to do with Java.
Relevance of your post to Java starts when you define your Java native method and run javah, ceases while you write, compile, and link your C code, and starts again when you are in a position to execute it.
OK, let's tackle it from another angle :). I will not ask how to change C code. But I'd like to ask what are the options of adapting Fortran 77 program (code) to use it with Java (adding GUI). That's a general quesiton, right? :). One can intercept inputs and outputs of the program. But what if I have to pass arguments from Java program into Fortran function and get result of that function, again, in Java program. What are my options?.
The question is so vague as to be unanswerable. All I can tell you is what JNI does. You define a native method in the Java syntax, so you are restricted to Java semantics as well: pass by value, Java datatypes, etc. You then generate a C header and stub file from that Java class. You then write the implementation(s) of the native method(s).
Matching that up to what you have to interface to isn't a Java question either.
935411 wrote:Well welcome to the wonderful world of C/C++ programming!
OK, let's tackle it from another angle :). I will not ask how to change C code.
The answer to your question is: a few years of schooling, half a dozen years of programming experience, the reading of a huge pile of books on a wide variety of subjects and doing actual coding on a daily basis. That's how I did it anyway. I'm glad I had that learning experience, I'm also glad I don't have to deal with it anymore.
Well, but we can talk about it and discuss it, or, perhaps, this is forbidden on this forum :) ?. And, please, correct JNI example. It may confuse beginner. Thanks for answers. I got, what I wanted, working (finally, uff).
Edited by: 935411 on 2012-05-22 05:25
935411 wrote:Stack overflow is more suited for cross-language discussions, this is the Java discussion forum.
Well, but we can talk about it and discuss it, or, perhaps, this is forbidden on this forum :) ?
. And, please, correct JNI example.You are mistaken. We're not Oracle employees.
It may confuse beginner.Beginners have no business even touching JNI. People who don't know C/C++ or the environment their programming for don't have either. People who are not beginners and/or know C/C++ won't be confused.
Well, but we can talk about it and discuss it, or, perhaps, this is forbidden on this forum :) ?How many times exactly do you have to be told that it's off topic?
It is also quite pointless. It's a Java Programming forum. People here are experts in Java programming. Not the Windows API. You can see that for yourself by the responses you've had over the last four days. Persisting with that discussion in the face of basically zero response isn't a rational strategy. Surely this is obvious?
And, please, correct JNI example.Submit a bug report. Again, this isn't the place to do that.