On 12 Nov 2005 04:55:48 -0800, "amatijaca@gmail.com"
<amatijaca@gmail.com> wrote, quoted or indirectly quoted someone who
said :
>I was wondering if somebody knows -- when JNI_CreateJavaVM
>executes from a C source code program, which java class gets
>actually invoked to create a new JVM? Sooner or later, the
>JNI_CreateJavaVM needs to look for a real Java class. Does
>anyone know, which Java class this is??
I don't think so. That would be a chicken and egg problem. A Java
class can't execute until it has a JVM environment to run in. C needs
to load the JVM into its own address space. A C-style exec would thus
not do. In Windows, a DLL style call would be required, possibly to
java.dll.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
amatijaca@gmail.com - 12 Nov 2005 13:48 GMT
Hmmm you are probably right, however, there is such a thing
as a Java compiler in tools.jar -- so, for example, your currently
running Java program can compile another (this is what happens
when JSPs are compiled -- javac.exe does not get invoked).
So, if one can call a java compiler from a running java program,
how does one running JVM create another (without going through
Runtime.getRuntime -- which is just a crutch in my opinion).. I
was thinking that JNI_CreateJavaVM kind of works the same way..
Thanks, Alex.
Roedy Green - 12 Nov 2005 14:12 GMT
On 12 Nov 2005 05:48:31 -0800, "amatijaca@gmail.com"
<amatijaca@gmail.com> wrote, quoted or indirectly quoted someone who
said :
>Hmmm you are probably right, however, there is such a thing
>as a Java compiler in tools.jar -- so, for example, your currently
>running Java program can compile another (this is what happens
>when JSPs are compiled -- javac.exe does not get invoked).
Your original post talked about spawning a JVM inside C in JNI, i.e.
the analog of firing up java.exe not javac.exe. Once you had a JVM
you could load the java compiler as an ordinary class. See
http://mindprod.com/jgloss/javacexe.html#MAIN
for how.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
> I was wondering if somebody knows -- when JNI_CreateJavaVM executes
> from a C source code program, which java class gets actually invoked
> to create a new JVM? Sooner or later, the JNI_CreateJavaVM needs to
> look for a real Java class. Does anyone know, which Java class this
> is??
The JVM is created "empty". You can then use it to invoke any method
in any class you want. i.e. it doesn't have to be static void main().
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e