Subject: How Can I Create Java-Native-Method?
From: [email-masked] (MIKEL)

22 Mar 1998 05:13:31 -0800
Message-ID: <01bd5306$78cf4280$06eba8c0.cygnus.gnu-win32@U-NETSURF>
Mime-Version: 1.0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_005B_01BD5351.E8B6EA80"
To: <[email-masked]>

This is a multi-part message in MIME format.

------=_NextPart_000_005B_01BD5351.E8B6EA80
Content-Type: text/plain;
	charset="iso-2022-jp"
Content-Transfer-Encoding: 7bit

Dear,

    I'm trying to integrate native code with Java programs.
    I implemented four steps as follows

       Step 1: Write th Java Code
       Step 2: Compile the Java Code
       Step 3: Create the .h File
       Step 4: Write the Native Method Implementation
       Step 5: Create a Shared Library

   But at Step 5, I cannot create a Shared Library.
   When I compile with "gcc -c HelloWorldImp.c", many parse error appears.

   <Error-message Examples>
      parse error before `jlong'
      parse error before `*'
      parse error before `}'
 
      parse error before `_declspecs'

            and so on       
  
   <HelloWorldImp.c>
      #include <jni.h>
      #include "HelloWorld.h"
      #include <stdio.h>
      JNIEXPORT void JNICALL 
      Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj) 
      {
           printf("Hello world!\n");
           return;
      } 

------=_NextPart_000_005B_01BD5351.E8B6EA80
Content-Type: text/html;
	charset="iso-2022-jp"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3D"text/html; charset=3DcsISO2022JP" =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.71.1712.3"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>Dear,</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp; I'm trying to =
integrate=20
native code with Java programs.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp; I implemented =
four steps as=20
follows</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Step 1:=20
Write th Java Code</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Step 2:=20
Compile the Java Code</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Step 3:=20
Create the .h File</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Step 4:=20
Write the Native Method Implementation</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Step 5:=20
Create a Shared Library</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp; But at Step 5, I cannot =
create a=20
Shared Library.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp; When I compile with =
&quot;gcc -c=20
HelloWorldImp.c&quot;, many parse error appears.</FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT><FONT =
size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp; &lt;Error-message =
Examples&gt;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parse error before=20
`jlong'</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parse error before=20
`*'</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parse error before=20
`}'</FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT color=3D#000000 =
size=3D2>&nbsp;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parse error before=20
`_declspecs'</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p; and so=20
on&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp; </FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;=20
&lt;HelloWorldImp.c&gt;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
#include=20
&lt;jni.h&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #include=20
&quot;HelloWorld.h&quot;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #include=20
&lt;stdio.h&gt;</FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
JNIEXPORT void=20
JNICALL <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
printf(&quot;Hello=20
world!\n&quot;);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;=20
return;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}&nbsp;</FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_005B_01BD5351.E8B6EA80--

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".