Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tool to generate C++ wrapper over java class

From what I understand, SWIG is to wrap C++/C to make it appear in Java, and javah is to implement certain java functions in C++ ( aka native functions ).
Is there a tool which can create a C++ wrapper over a java class, so that the caller. of this c++ wrapper doesn't have to worry about java, for example
Input Java is

  class hw {  
    public  void hi() {  
      System.out.println("Hello World");  
    }  
  }  

Tools outputs hw.hh ( and some. c++ files ), which can be used as:

hw *h = new hw(/*JEnv */ env);
h->hi();

Is there a tool available which can do this ?

like image 530
vrdhn Avatar asked Dec 27 '10 04:12

vrdhn


2 Answers

Options include, the following, in ascending order of expense to you.

  • Hand-written JNI code written by clients of your Java class.
  • Hand-written, JNI-driven wrappers written by you for clients of your class.
  • JACE-generated wrappers. JACE is a free tool. Last version was in 2008; not sure if development is continuing.
  • JunC++ion-generated wrappers. This commercial library produces the best results with the least development effort. It supports Java callbacks, with C++ classes implementing Java interfaces. The author is very responsive and a very nice guy. However, there is a price tag, and you'll want to be sure about deployment costs.
like image 173
Andy Thomas Avatar answered Sep 19 '22 03:09

Andy Thomas


I used this product a long time ago, http://www.codemesh.com/products/junction/

It will do exactly what you want.

Just a disclaimer, I used it almost 6 years ago. I am not affliated with this product.

like image 34
Andrew T Finnell Avatar answered Sep 19 '22 03:09

Andrew T Finnell