I wrote a function to access a printer in c++, how can i call that method from java.
calling c++ code from java
Page 1 of 12 Replies - 457 Views - Last Post: 27 July 2010 - 06:28 AM
Replies To: calling c++ code from java
#2
Re: calling c++ code from java
Posted 27 July 2010 - 12:48 AM
This article might prove useful.
Also, you could try finding a similar method in java. It might be easier than importing the c++ code. I don't how complicated your method is though..
Also, you could try finding a similar method in java. It might be easier than importing the c++ code. I don't how complicated your method is though..
#3
Re: calling c++ code from java
Posted 27 July 2010 - 06:28 AM
Here is a good book on how to use JNI.
Basically you are just making a dll that will be loaded by Java which will call that native method. To get there though you will need to first sketch the class in Java that will use the function, let Javah generate the headers that you need (the functions need signatures that java can understand) and then use that to create the C/C++ code and then compile as a dll. I have done a couple of routines myself and it really is not hard although I had a couple of issues with linking myself.
here is another tutorial and if you google for "Using JNI" you will find lots of various examples.
However, you DO know that java has the ability to use the printer... no real need for a native interface for that.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|