Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7816355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:50:18+00:00 2026-06-02T05:50:18+00:00

I haven’t seen this anywhere (or maybe I’m jsut simple not seeing it) but

  • 0

I haven’t seen this anywhere (or maybe I’m jsut simple not seeing it) but is there a way to use JNI to return the c/c++ object and use that object in java?

For example (very simple):

class simpleClass{
...
private:
int intVar;
public:
int getIntVar();
void setIntVar(int someNum);
...
}

In my java code, how would I go about doing something like:

...
simpleClass sc = new simpleClass();
sc.setIntVar(9);
System.out.println(sc.getIntVar());
...

I realize this is a VERY simplistic example but I’m just looking for concept – the class I have in mind that is in c++ is very large and am looking to avoid creating a TON of wrapper methods…

If it’s not possible that’s fine, just hoping to save a few days coding lol

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:50:20+00:00Added an answer on June 2, 2026 at 5:50 am

    No you can’t. The C++ and Java ABIs are completely different – for one, c++ doesn’t define one. And really c++ has so many features that can’t be mapped to Java at all this just can’t work. How do you expect Java would handle c++ templates? Pointers to primitives? Objects that aren’t pointers?

    Now what you can do, is use SWIG to generate the right wrapper methods for you – that will actually work and is not much more work than what you planned 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I haven't found information about this anywhere. Is there a minimal required length for
I haven't seen this on the Android docs. Is it safe to use this
Haven't seen this feature anywhere else. I know that the 32nd bit is used
Haven't seen anything about it here but it seems to solve one of the
I haven't used the STL much before, but I started to on this huffman
Haven't seen anything, but I have seen that you can create albums in the
Haven't found this in my search on Stackoverflow - I know I've seen a
Haven't seen this before so hopefully someone has a easy solve, I have a
Haven't seen many Geneva related questions yet, I have posted this question in the
I haven't been able to get this working and all of the sample code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.