📄 从 java 程序调用 c-c++ 代码1.htm
字号:
method=get>
<TBODY>
<TR>
<TD colSpan=6><IMG height=4 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=390 border=0></TD></TR>
<TR vAlign=center>
<TD class=dwsearch height=8><SELECT class=dwsearch
name=selScope><OPTION value=dW selected>dW 中国所有内容</OPTION><OPTION
value=dW>.................</OPTION><OPTION value=dW>dW
中国技术专区:</OPTION><OPTION value=comptZ> 组件技术</OPTION><OPTION
value=javaZ> Java 技术</OPTION><OPTION
value=linuxZ> Linux</OPTION><OPTION
value=xmlZ> XML</OPTION><OPTION value=linuxZ>dW
中国特别专题:</OPTION><OPTION value=securityZ> 安全</OPTION><OPTION
value=unicodeZ> Unicode</OPTION><OPTION value=all>IBM
全部内容</OPTION></SELECT></TD>
<TD class=small><IMG height=1 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=5 border=0></TD>
<TD><INPUT class=dwsearch maxLength=100 size=15 name=UserRestriction
height="15"></TD>
<TD><IMG height=1 alt="" src="从 Java 程序调用 C-C++ 代码1.files/c.gif"
width=5 border=0></TD>
<TD width=64><INPUT type=image height=23 alt=搜索 width=64
src="从 Java 程序调用 C-C++ 代码1.files/search.gif" value=Search border=0
name=Search></TD>
<TD vAlign=top><IMG height=1 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=34 border=0></TD></TR>
<TR vAlign=top>
<TD class=small colSpan=6><A style="COLOR: #ffffff"
href="http://www-128.ibm.com/developerworks/cn/search/help-dw.html"
target=_blank>高级搜索</A><IMG height=1 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=1 border=0></TD></TR>
<TR>
<TD colSpan=6><IMG height=4 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=390
border=0></TD></TR></FORM></TBODY></TABLE></TD></TR>
<TR>
<TD class=hbg width=160 height=21></TD>
<TD class=bbg vAlign=top colSpan=2 height=21> <A class=mainlink
href="http://www-900.ibm.com/cn/">IBM 主页</A><SPAN class=divider> |
</SPAN><A class=mainlink
href="http://www-900.ibm.com/cn/products/index.shtml">产品与服务</A><SPAN
class=divider> | </SPAN><A class=mainlink
href="http://www-900.ibm.com/cn/support/index.shtml">支持与下载</A><SPAN
class=divider> | </SPAN><A class=mainlink
href="http://www-900.ibm.com/cn/account/index.shtml">个性化服务</A></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width=150 bgColor=#ffffff height=1><IMG height=1 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=150></TD></TR>
<TR>
<TD width=150 bgColor=#cc6633 height=3><IMG height=3 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=150></TD></TR>
<TR>
<TD width=150 bgColor=#333333 height=1><IMG height=1 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=150></TD></TR>
<TR>
<TD width=150 bgColor=#000000 height=1><IMG height=1 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=150></TD></TR>
<TR>
<TD width=150 bgColor=#ffffff height=1><IMG height=2 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=150></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><FONT face="Verdana, sans-serif" size=-1><A
href="http://www.ibm.com/">IBM</A> : <A
href="http://www.ibm.com/developerworks/cn/index.html">developerWorks
中国网站</A> : <A
href="http://www-128.ibm.com/developerworks/cn/java/index.html">Java</A> :
<A
href="http://www-128.ibm.com/developerworks/cn/views/java/tutorials.jsp">教学
- 在线教程</A></FONT> <BR><IMG alt="用 JNI 进行 Java 编程"
src="从 Java 程序调用 C-C++ 代码1.files/masthead.jpg"></TD>
<TD vAlign=bottom align=right width=*><A
href="https://www6.software.ibm.com/developerworks/cn/education/java/j-jni/tutorial/j-jni.zip"
border="0"><IMG alt="下载 ZIP 文件"
src="从 Java 程序调用 C-C++ 代码1.files/icon-zip.gif" border=0></A><IMG alt=英文原文
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" border=0>
</TD></TR>
<TR>
<TD colSpan=2 height=2><IMG height=2 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=1></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width=150 bgColor=#000000 colSpan=6 height=1><IMG height=1 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=150></TD></TR>
<TR>
<TD background="从 Java 程序调用 C-C++ 代码1.files/sw-gold.gif"><A
onmouseover="iOver('topmain'); iOver('bottommain'); self.status=mainblurb; return true;"
onmouseout="iOut('topmain'); iOut('bottommain'); self.status=''; return true;"
href="https://www6.software.ibm.com/developerworks/cn/education/java/j-jni/tutorial/index.html"
border="0"><IMG alt=主菜单 src="从 Java 程序调用 C-C++ 代码1.files/main.gif"
border=0 name=topmain></A></TD>
<TD background="从 Java 程序调用 C-C++ 代码1.files/sw-gold.gif"><A
onmouseover="iOver('topsection'); iOver('bottomsection'); self.status=sectionblurb; return true;"
onmouseout="iOut('topsection'); iOut('bottomsection'); self.status=''; return true;"
href="https://www6.software.ibm.com/developerworks/cn/education/java/j-jni/tutorial/index2.html"
border="0"><IMG alt=章节菜单 src="从 Java 程序调用 C-C++ 代码1.files/section.gif"
border=0 name=topsection></A></TD>
<TD background="从 Java 程序调用 C-C++ 代码1.files/sw-gold.gif"><A
onmouseover="iOver('topfeedback'); iOver('bottomfeedback'); self.status=feedbackblurb; return true;"
onmouseout="iOut('topfeedback'); iOut('bottomfeedback'); self.status=''; return true;"
href="https://www6.software.ibm.com/developerworks/cn/education/java/j-jni/tutorial/j-jni-5-3.html"
border="0"><IMG alt=给出此教程的反馈意见
src="从 Java 程序调用 C-C++ 代码1.files/feedback.gif" border=0
name=topfeedback></A></TD>
<TD width="100%" background="从 Java 程序调用 C-C++ 代码1.files/sw-gold.gif"><IMG
alt="" src="从 Java 程序调用 C-C++ 代码1.files/c.gif"></TD>
<TD background="从 Java 程序调用 C-C++ 代码1.files/sw-gold.gif"><A
onmouseover="iOver('topprevious'); iOver('bottomprevious'); self.status=previousblurb; return true;"
onmouseout="iOut('topprevious'); iOut('bottomprevious'); self.status=''; return true;"
href="https://www6.software.ibm.com/developerworks/cn/education/java/j-jni/tutorial/j-jni-2-1.html"
border="0"><IMG alt=上页 src="从 Java 程序调用 C-C++ 代码1.files/previous.gif"
border=0 name=topprevious></A></TD>
<TD background="从 Java 程序调用 C-C++ 代码1.files/sw-gold.gif"><A
onmouseover="iOver('topnext'); iOver('bottomnext'); self.status=nextblurb; return true;"
onmouseout="iOut('topnext'); iOut('bottomnext'); self.status=''; return true;"
href="https://www6.software.ibm.com/developerworks/cn/education/java/j-jni/tutorial/j-jni-2-3.html"
border="0"><IMG alt=下页 src="从 Java 程序调用 C-C++ 代码1.files/next.gif" border=0
name=topnext></A></TD></TR></TBODY></TABLE>
<TABLE height=400 cellSpacing=0 cellPadding=2 width="100%" bgColor=#ffffff
border=0>
<TBODY>
<TR vAlign=bottom></A><A name=navskip></A>
<TD colSpan=4 height=25><IMG height=25 alt="2.从 Java 程序调用 C/C++ 代码"
src="从 Java 程序调用 C-C++ 代码1.files/titlebar2.jpg" width=562 border=0></TD></TR>
<TR>
<TD width=15 bgColor=#ffffff> </TD>
<TD width=12 bgColor=#ffffff> </TD>
<TD vAlign=top align=left width=* bgColor=#ffffff>
<P><BR>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD width="90%"><FONT face="Verdana, Arial, Helvetica" size=4><B>从
Java 代码调用 C/C++ 的六个步骤</B></FONT></TD>
<TD align=right width=200><FONT face="Verdana, Arial, Helvetica"
size=1><NOBR>第 2 页(共16
页)</NOBR></FONT></TD></TR></TBODY></TABLE><BR><BR></P><FONT
face="Verdana, Arial, Helvetica" size=2>
<P>从 Java 程序调用 C 或 C ++
代码的过程由六个步骤组成。我们将在下面几页中深入讨论每个步骤,但还是先让我们迅速地浏览一下它们。</P>
<P>
<OL>
<LI><B>编写 Java 代码</B>。我们将从编写 Java
类开始,这些类执行三个任务:声明将要调用的本机方法;装入包含本机代码的共享库;然后调用该本机方法。<BR><BR>
<LI><B>编译 Java 代码</B>。在使用 Java 类之前,必须成功地将它们编译成字节码。<BR><BR>
<LI><B>创建 C/C++ 头文件</B>。C/C++ 头文件将声明想要调用的本机函数说明。然后,这个头文件与 C/C++
函数实现(请参阅步骤 4)一起来创建共享库(请参阅步骤 5)。<BR><BR>
<LI><B>编写 C/C++ 代码</B>。这一步实现 C 或 C++ 源代码文件中的函数。C/C++ 源文件必须包含步骤 3
中创建的头文件。<BR><BR>
<LI><B>创建共享库文件</B>。从步骤 4 中创建的 C 源代码文件来创建共享库文件。<BR><BR>
<LI><B>运行 Java 程序</B>。运行该代码,并查看它是否有用。我们还将讨论一些用于解决常见错误的技巧。 </LI></OL>
<P></P><BR></FONT></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD background="从 Java 程序调用 C-C++ 代码1.files/sw-gold.gif"><A
onmouseover="iOver('topmain'); iOver('bottommain'); self.status=mainblurb; return true;"
onmouseout="iOut('topmain'); iOut('bottommain'); self.status=''; return true;"
href="https://www6.software.ibm.com/developerworks/cn/education/java/j-jni/tutorial/index.html"
border="0"><IMG alt=主菜单 src="从 Java 程序调用 C-C++ 代码1.files/main.gif"
border=0 name=bottommain></A></TD>
<TD background="从 Java 程序调用 C-C++ 代码1.files/sw-gold.gif"><A
onmouseover="iOver('topsection'); iOver('bottomsection'); self.status=sectionblurb; return true;"
onmouseout="iOut('topsection'); iOut('bottomsection'); self.status=''; return true;"
href="https://www6.software.ibm.com/developerworks/cn/education/java/j-jni/tutorial/index2.html"
border="0"><IMG alt=章节菜单 src="从 Java 程序调用 C-C++ 代码1.files/section.gif"
border=0 name=bottomsection></A></TD>
<TD background="从 Java 程序调用 C-C++ 代码1.files/sw-gold.gif"><A
onmouseover="iOver('topfeedback'); iOver('bottomfeedback'); self.status=feedbackblurb; return true;"
onmouseout="iOut('topfeedback'); iOut('bottomfeedback'); self.status=''; return true;"
href="https://www6.software.ibm.com/developerworks/cn/education/java/j-jni/tutorial/j-jni-5-3.html"
border="0"><IMG alt=给出此教程的反馈意见
src="从 Java 程序调用 C-C++ 代码1.files/feedback.gif" border=0
name=bottomfeedback></A></TD>
<TD width="100%" background="从 Java 程序调用 C-C++ 代码1.files/sw-gold.gif"><IMG
alt="" src="从 Java 程序调用 C-C++ 代码1.files/c.gif"></TD>
<TD background="从 Java 程序调用 C-C++ 代码1.files/sw-gold.gif"><A
onmouseover="iOver('topprevious'); iOver('bottomprevious'); self.status=previousblurb; return true;"
onmouseout="iOut('topprevious'); iOut('bottomprevious'); self.status=''; return true;"
href="https://www6.software.ibm.com/developerworks/cn/education/java/j-jni/tutorial/j-jni-2-1.html"
border="0"><IMG alt=上页 src="从 Java 程序调用 C-C++ 代码1.files/previous.gif"
border=0 name=bottomprevious></A></TD>
<TD background="从 Java 程序调用 C-C++ 代码1.files/sw-gold.gif"><A
onmouseover="iOver('topnext'); iOver('bottomnext'); self.status=nextblurb; return true;"
onmouseout="iOut('topnext'); iOut('bottomnext'); self.status=''; return true;"
href="https://www6.software.ibm.com/developerworks/cn/education/java/j-jni/tutorial/j-jni-2-3.html"
border="0"><IMG alt=下页 src="从 Java 程序调用 C-C++ 代码1.files/next.gif" border=0
name=bottomnext></A></TD></TR>
<TR>
<TD width=150 bgColor=#000000 colSpan=6 height=1><IMG height=1 alt=""
src="从 Java 程序调用 C-C++ 代码1.files/c.gif" width=150></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width="100%">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=1 alt="" src="从 Java 程序调用 C-C++ 代码1.files/c.gif"
width=1></TD></TR>
<TR vAlign=top>
<TD class=bbg height=21> <A class=mainlink
href="http://www-900.ibm.com/cn/ibm/index.shtml">关于 IBM</A><SPAN
class=divider> | </SPAN><A class=mainlink
href="http://www-900.ibm.com/cn/ibm/privacy/index.shtml">隐私条约</A><SPAN
class=divider> | </SPAN><A class=mainlink
href="http://www-900.ibm.com/cn/ibm/legal/index.shtml">法律条款</A><SPAN
class=divider> | </SPAN><A class=mainlink
href="http://www-900.ibm.com/cn/ibm/contact/index.shtml">联系
IBM</A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<SCRIPT language=JavaScript1.2 src="从 Java 程序调用 C-C++ 代码1.files/stats.js"
type=text/javascript></SCRIPT>
<NOSCRIPT><IMG height=1 alt="" src="G:\ye\从 Java 程序调用 C-C++ 代码1.files\c(1).gif"
width=1 border=0></NOSCRIPT> </BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -