0

I want to use some .cpp class and methods in my java program. For example, I have p1.java that calls method1. method1 is available in p2.cpp and p2.cpp includes p3.cpp. I don't want to change cpp codes...

Is it possible? (and I need .cpp and .header both.)

And is there any alternative better solution? (except java native interface)?

1 Answer 1

2

Why don't you create an extra layer between Java and C++ with JNI - effectively you create:

method1_java_cpp_layer( JNIEnv * e, jobject o )
{
    extracted_information = extract_information( e, o );
    method1( extracted_information )
}

And this goes into "java_cpp_layer.cpp".

Sign up to request clarification or add additional context in comments.

1 Comment

Thank's... . I did that. But now when i run program(java java_cpp_layer) I get another error:libjava_cpp_layer.so: undefined symbol: p2 ...Can you help me?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.