Calling JVM from a C program

O

Olivier Merigon

Hello,

Is there a solid documentation about invoking the JVM from a C program ?
By solid I mean more than 200 words, younger than 5 years old, not a 100$
book. Sun's web site only offers very old and short stuff.

My aim is to built a stand alone C aplication that is able to use java
classes. I have read the sun's tutorial but it is never mentionned what is
needed by the jvm.dll to run. Do we have to include rt.jat in the classpath
? What become the 30 megs of files from the lib folder of the JRE (images,
audio, fonts, ext...) ? Do we need a JRE to be installed on the computer in
fact.

In fact I need to know what is necessary to bundle in my stand alone C
application in order to run Java code with the JVM invokation API ?

Regards,



Olivier MERIGON
 
C

Cid

Hello,

Is there a solid documentation about invoking the JVM from a C program ?
By solid I mean more than 200 words, younger than 5 years old, not a 100$
book. Sun's web site only offers very old and short stuff.

My aim is to built a stand alone C aplication that is able to use java
classes. I have read the sun's tutorial but it is never mentionned what is
needed by the jvm.dll to run. Do we have to include rt.jat in the classpath
? What become the 30 megs of files from the lib folder of the JRE (images,
audio, fonts, ext...) ? Do we need a JRE to be installed on the computer in
fact.

In fact I need to know what is necessary to bundle in my stand alone C
application in order to run Java code with the JVM invokation API ?


Sounds like a good candidate for CORBA to me. See if that floats your
boat.

http://java.sun.com/docs/books/tutorial/idl/index.html
 
C

Chris Uppal

Olivier said:
Is there a solid documentation about invoking the JVM from a C program
? By solid I mean more than 200 words, younger than 5 years old, not a
100$ book. Sun's web site only offers very old and short stuff.

http://java.sun.com/docs/books/jni/

The whole book online...

You'll find that most material (including the spec and the above book) assume
that almost all users of JNI will be wanting to call C (or whatever) from Java
not the otherway around. That assumption is false in general, and -- I
suspect -- false far more often than the books would lead you to suspect.

Still, there are few aspects of using Java from C that that not lavishly
covered by the usual material. The biggest is about how to start a runtime
JVM. They break down into three categories:

- stuff that is covered briefly but (mostly) adequately in the spec and
books.

- stuff that is JVM, OS, and programming language/compiler dependent.

- stuff that should be bleeding obvious to any C programmer.

I'd advise you to first ensure that you know:

- how to do "normal" JNI programming -- invoking C from Java -- it'll
really help
keep the complexity under control if you learn one thing at a time.

- how to program, toubleshoot, and debug whatever your platform's
equivalent of a Windows DLL is.

And yes, you will need the entire JRE, mostly for technical reasons, but also
because the licence doesn't (AFIAK) permit you to bundle only /part/ of the
JRE.

-- chris
 
O

Olivier Merigon

Thanks for your answer but the java code I need to run from my c application
are EJBs clients.

Olivier
 
J

Jim Sculley

Olivier said:
Hello,

Is there a solid documentation about invoking the JVM from a C program ?
By solid I mean more than 200 words, younger than 5 years old, not a 100$
book. Sun's web site only offers very old and short stuff.

All still accurate though. JNI hasn't changed much. The online book
has undergone a recent facelift and has the latest stuff in it:

http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/jniTOC.html
My aim is to built a stand alone C aplication that is able to use java
classes. I have read the sun's tutorial but it is never mentionned what is
needed by the jvm.dll to run.

A JRE.
Do we have to include rt.jat in the classpath

You have to include a JRE.
? What become the 30 megs of files from the lib folder of the JRE (images,
audio, fonts, ext...) ? Do we need a JRE to be installed on the computer in
fact.

Yes. Or you can distribute the JRE with your app, unless you want to
bother the user with pointing you to it, or detecting it yourself.
In fact I need to know what is necessary to bundle in my stand alone C
application in order to run Java code with the JVM invokation API ?

A JRE.


Jim S.
 

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
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top