<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[jvm jni]]></title><description><![CDATA[<p>moin,</p>
<pre><code>#include &quot;stdafx.h&quot; 
#include &quot;jni.h&quot;
#include &quot;windows.h&quot; 

typedef jint (WINAPI* JNI_CREATEJAVAVM)(JavaVM **pvm, void ** penv, void *args); 

int main(int argc, char* argv[]) 
{ 
	JavaVMInitArgs vm_args; 
	JavaVMOption options[10]; 
	JavaVM* jvm; 
	JNIEnv* env; 

	options[0].optionString = &quot;-Djava.compiler=NONE&quot;; 
	options[1].optionString = &quot;-Djava.class.path=D:/programme/eclipse/workspace/helloworld&quot;; 

	vm_args.version  = JNI_VERSION_1_4; 
	vm_args.nOptions = 2; 
	vm_args.options  = options; 
	vm_args.ignoreUnrecognized = JNI_FALSE; 
	JNI_CREATEJAVAVM JNI_CreateJavaVM = 0; 

	HMODULE hLib = LoadLibrary(_T(&quot;D:/Programme/Java/jdk1.5.0_06/jre/bin/client/jvm.dll&quot;)); 

	JNI_CreateJavaVM = (JNI_CREATEJAVAVM) GetProcAddress(hLib, &quot;JNI_CreateJavaVM&quot;); 
	long status  = JNI_CreateJavaVM(&amp;jvm, (void**) &amp;env, &amp;vm_args); 
	jclass cls = (*env).FindClass(&quot;HelloWorld&quot;);
	jmethodID mid = (*env).GetStaticMethodID(cls, &quot;main&quot;, &quot;([Ljava/lang/String;)V&quot;);
	(*env).CallStaticVoidMethod(cls, mid,NULL);

	jvm-&gt;DestroyJavaVM();
	return 0; 
}
</code></pre>
<p>kann mir jemand den typedef erklähren?<br />
weil eigentlich sollte dieser aufruf genügen</p>
<pre><code>status = JNI_CreateJavaVM(&amp;jvm, (void**)&amp;env, &amp;vm_args);
</code></pre>
<p>gibt allerdings fehler</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/164326/jvm-jni</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Jul 2026 21:46:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/164326.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 Nov 2006 10:09:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to jvm jni on Tue, 07 Nov 2006 10:09:29 GMT]]></title><description><![CDATA[<p>moin,</p>
<pre><code>#include &quot;stdafx.h&quot; 
#include &quot;jni.h&quot;
#include &quot;windows.h&quot; 

typedef jint (WINAPI* JNI_CREATEJAVAVM)(JavaVM **pvm, void ** penv, void *args); 

int main(int argc, char* argv[]) 
{ 
	JavaVMInitArgs vm_args; 
	JavaVMOption options[10]; 
	JavaVM* jvm; 
	JNIEnv* env; 

	options[0].optionString = &quot;-Djava.compiler=NONE&quot;; 
	options[1].optionString = &quot;-Djava.class.path=D:/programme/eclipse/workspace/helloworld&quot;; 

	vm_args.version  = JNI_VERSION_1_4; 
	vm_args.nOptions = 2; 
	vm_args.options  = options; 
	vm_args.ignoreUnrecognized = JNI_FALSE; 
	JNI_CREATEJAVAVM JNI_CreateJavaVM = 0; 

	HMODULE hLib = LoadLibrary(_T(&quot;D:/Programme/Java/jdk1.5.0_06/jre/bin/client/jvm.dll&quot;)); 

	JNI_CreateJavaVM = (JNI_CREATEJAVAVM) GetProcAddress(hLib, &quot;JNI_CreateJavaVM&quot;); 
	long status  = JNI_CreateJavaVM(&amp;jvm, (void**) &amp;env, &amp;vm_args); 
	jclass cls = (*env).FindClass(&quot;HelloWorld&quot;);
	jmethodID mid = (*env).GetStaticMethodID(cls, &quot;main&quot;, &quot;([Ljava/lang/String;)V&quot;);
	(*env).CallStaticVoidMethod(cls, mid,NULL);

	jvm-&gt;DestroyJavaVM();
	return 0; 
}
</code></pre>
<p>kann mir jemand den typedef erklähren?<br />
weil eigentlich sollte dieser aufruf genügen</p>
<pre><code>status = JNI_CreateJavaVM(&amp;jvm, (void**)&amp;env, &amp;vm_args);
</code></pre>
<p>gibt allerdings fehler</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1170284</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1170284</guid><dc:creator><![CDATA[nameac]]></dc:creator><pubDate>Tue, 07 Nov 2006 10:09:29 GMT</pubDate></item><item><title><![CDATA[Reply to jvm jni on Tue, 07 Nov 2006 10:12:25 GMT]]></title><description><![CDATA[<p>Was für Fehler kommen denn?</p>
<p>(eventuell solltest du mal überprüfen, ob die LoadLibrary() und GetProcAdress() Aufrufe erfolgreich waren, bevor du weiter arbeitest)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1170287</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1170287</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 07 Nov 2006 10:12:25 GMT</pubDate></item><item><title><![CDATA[Reply to jvm jni on Tue, 07 Nov 2006 10:38:56 GMT]]></title><description><![CDATA[<p>ne das programm funktioniert ich wollt nur wissen was das fürn typedef ist weil man braucht ja einen int in c auch nicht vorher definieren genauso eine prinf funktion ich kenn mich halt nicht so gut in c aus und wollt wissen was der typedef für ne bedeutung hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1170310</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1170310</guid><dc:creator><![CDATA[nameac]]></dc:creator><pubDate>Tue, 07 Nov 2006 10:38:56 GMT</pubDate></item><item><title><![CDATA[Reply to jvm jni on Tue, 07 Nov 2006 10:45:34 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=403" rel="nofollow">HumeSikkins</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=8" rel="nofollow">Rund um die Programmierung</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1170316</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1170316</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Tue, 07 Nov 2006 10:45:34 GMT</pubDate></item><item><title><![CDATA[Reply to jvm jni on Tue, 07 Nov 2006 10:54:58 GMT]]></title><description><![CDATA[<p>Der Typ ist ein Funktionszeiger - den verwendest du z.B., wenn du eine Funktion erst zur Laufzeit festlegen willst (in deinem Beispiel ist 'JNI_CreateVM' ein Zeiger auf eine Funktion, die einen JavaVM** und zwei void** nimmt und einen jint zurückliefert - und den biegst du auf eine Adresse in der DLL).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1170324</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1170324</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 07 Nov 2006 10:54:58 GMT</pubDate></item><item><title><![CDATA[Reply to jvm jni on Tue, 07 Nov 2006 11:28:30 GMT]]></title><description><![CDATA[<p>und warum steht da ein WINAPI davor? zu 1.) wenn ich das richtig verstanden habe muss der typedef gesetzt werden weil die funktion aus der jvm.dll erst zur laufzeit hinzugefügt wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1170350</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1170350</guid><dc:creator><![CDATA[nameac]]></dc:creator><pubDate>Tue, 07 Nov 2006 11:28:30 GMT</pubDate></item><item><title><![CDATA[Reply to jvm jni on Tue, 07 Nov 2006 11:38:12 GMT]]></title><description><![CDATA[<p>nameac schrieb:</p>
<blockquote>
<p>und warum steht da ein WINAPI davor?</p>
</blockquote>
<p>Das dürfte die Aufrufkonvention sein (das sind Festelgungen, wie die Funktion ihre Parameter erhalten soll)</p>
<blockquote>
<p>zu 1.) wenn ich das richtig verstanden habe muss der typedef gesetzt werden weil die funktion aus der jvm.dll erst zur laufzeit hinzugefügt wird.</p>
</blockquote>
<p>Muß nicht - aber es erleichtert die Schreibweise. Du kannst auch den kompletten Typ stattdessen angeben, wenn du deinen Zeiger anlegst:</p>
<pre><code class="language-cpp">jint (WINAPI* CreateVM)(JavaVM**,void**,void**) = (jint (WINAPI*)(JavaVM**,void**,void**)) GetProcAdress(hLib,&quot;JNI_CreateJavaVM&quot;);
</code></pre>
<p>(sieht schlimm aus, nicht wahr? und an der Stelle bin ich mir nichtmal sicher, ob ich die Klammern richtig gesetzt habe)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1170361</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1170361</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 07 Nov 2006 11:38:12 GMT</pubDate></item></channel></rss>