can I use a .jar file directly in C++?

T

tony_lincoln

Dear friends,

In order to call Java from C++, can I use a .jar file directly in C++?
Thanks a lot.
tony
 
G

Gordon Beaton

In order to call Java from C++, can I use a .jar file directly in C++?

Depends what you mean by "use". Try to be more specific about what you
want to do.

While your C++ code can probably read and extract classes found in the
jar file, it will not be able to call their methods "directly" if
that's what you mean.

JNI requires a JVM, regardless of whether you are calling from Java to
C++ or C++ to java. JNI also provides mechanisms for starting a JVM if
one isn't already running.

Simply make sure the JVM you start (or a classloader you initialize)
has the jar in its classpath. It will take care of classloading for
you, and you will be able to use those classes from your C++ code
transparently.

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top