Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

JNI_CreateJavaVM

Thread view: 
amatijaca@gmail.com - 12 Nov 2005 12:55 GMT
Hi there,

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??

Thanks, Alex.
Roedy Green - 12 Nov 2005 13:26 GMT
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.

Gordon Beaton - 12 Nov 2005 14:08 GMT
> 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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.