• Post Reply Bookmark Topic Watch Topic
  • New Topic

integrating Java with #C, having issues  RSS feed

 
Oz Kron
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I have read this file
web page

I have mangged to compile a simpe java to C and so on
But
How do I compile the exmpales in this doc? I don't know that much of c#
Also
How can I save a state when using JNI ?!
Can someone please explain it to me?
 
Oz Kron
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
web page
Here is anthor link to examples
Hope someone can help me out here
 
Oz Kron
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone please help me out here?
 
Henry Wong
author
Sheriff
Posts: 22856
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By C#, I am assuming that you want to get to a .NET library. So...

Unfortunately, you need to make two hops to get to the .NET library. JNI will get you from Java to C/C++. However, unmanaged C++ code is not allowed to have .NET objects.

To do that, you will have to write a managed C++ class (which will be a .NET object), with static methods, that can be called from the unmanaged C++ code. The reason the static method works, is because you don't need a reference to call a static method.

Henry
[ March 03, 2007: Message edited by: Henry Wong ]
 
Henry Wong
author
Sheriff
Posts: 22856
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I compile the exmpales in this doc? I don't know that much of c#
Also How can I save a state when using JNI ?!


To compile C# code, you need a C# compiler. Personally, I use Microsoft Visual Studio, which may be an overkill, since it is an IDE.

Not sure what you mean by "save a state using JNI". JNI will get you to C++, you can, at this point, save the state using C++, or make a call back to Java (using the JEnv) to save the state.

Henry
 
Oz Kron
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all
Tanx
Now
I can get a .net compiler
But, how can I do compile it?
There seem to be there 3 files
C
mangged C and the .net C# one
How do I get all of them to be a .dll?
And for state I mean
I want to call the function read_file from c#
but
I don't want the file_position ot start every time from start, I want the static .dll to continue being used from the last place I have used it
(More complex then just printf "hello world")
 
Oz Kron
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So
Can someone just explain me simply how to compile the all thing?
Even just as simple "hello world" written in C# ?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Oz Kron:
So
Can someone just explain me simply how to compile the all thing?
Even just as simple "hello world" written in C# ?


You'd want to go to a C# forum for that, yes? Or buy a C# programming book.
 
Oz Kron
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No you don't understand
I know for example how to just compile a simple c# example
but
I want to do it for JNI, intergrating it with JAVA
How can I do that?
 
Henry Wong
author
Sheriff
Posts: 22856
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Oz Kron:
No you don't understand
I know for example how to just compile a simple c# example
but
I want to do it for JNI, intergrating it with JAVA
How can I do that?


Actually, EFH understands correctly. JNI will get to C/C++ code in the DLL (which are simple C/C++ function code defined by "javah"), but it assumes that you know how to compile it to a DLL. The docs on the sun site, does give a few examples, but it is not a tutorial on C/C++, it assumes that you understand C/C++, and especially, how to use your C/C++ compiler.

As for C#, JNI will only get you to C/C++, you have to get to C# from there.

Henry
[ March 04, 2007: Message edited by: Henry Wong ]
 
Oz Kron
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah
Well I know how to create DLL file
The problem is creating one that combine the c\C++ and c#
How can I do that?!
 
Henry Wong
author
Sheriff
Posts: 22856
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Oz Kron:
Yeah
Well I know how to create DLL file
The problem is creating one that combine the c\C++ and c#
How can I do that?!


Please read the documentation that came with your c/c++/c# compiler. This is *not* a Java related question.

Henry
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!