﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-StarLover</title><link>http://www.blogjava.net/StarLover/</link><description>To find the lost memorise...</description><language>zh-cn</language><lastBuildDate>Thu, 30 Apr 2026 06:24:48 GMT</lastBuildDate><pubDate>Thu, 30 Apr 2026 06:24:48 GMT</pubDate><ttl>60</ttl><item><title>关于在服务器和客户端传送对象的问题</title><link>http://www.blogjava.net/StarLover/archive/2005/12/21/24903.html</link><dc:creator>StarLover</dc:creator><author>StarLover</author><pubDate>Wed, 21 Dec 2005 01:11:00 GMT</pubDate><guid>http://www.blogjava.net/StarLover/archive/2005/12/21/24903.html</guid><wfw:comment>http://www.blogjava.net/StarLover/comments/24903.html</wfw:comment><comments>http://www.blogjava.net/StarLover/archive/2005/12/21/24903.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/StarLover/comments/commentRss/24903.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/StarLover/services/trackbacks/24903.html</trackback:ping><description><![CDATA[<SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><IMG height=20 src="http://www.blogjava.net/Emoticons/QQ/shifty.gif" width=20 border=0>一般我们知道在</SPAN><SPAN lang=EN-US>JAVA</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">程序中可以用</SPAN><SPAN lang=EN-US>ObjectOutputStream</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类来传送对象，在网络上更加显示了其的功能强大，最近在做一个网络对战平台，其间需要很多传送对象的地方，开始并没太在意，但在开发中遇到后，却让我困惑不已，从客户端传往服务器端的对象，被服务器端接收读取后，却报了</SPAN><SPAN lang=EN-US>ClassNotFoundException</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">异常，难道是我没初始化？检查了所有代码，找不到原因，也请同学，朋友帮我看了代码，都找不到原因，一个偶然的机会，发现了服务器端报出的异常中出现了包名（<IMG height=20 src="http://www.blogjava.net/Emoticons/QQ/11.gif" width=20 border=0>两天后才注意到的），注意到了在服务器端的</SPAN><SPAN lang=EN-US>.class</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件放置与客户端的不一致，于是将传送的类在客户端的路径记下，也将服务器端的相应的类的路径改为与客户端一致，问题总算解决了，希望这两天的困惑对大家又用吧。。。。。。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">开始的时候所传送类在：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">服务器端打包：</SPAN><SPAN lang=EN-US>package com..cz;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: 21pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">客户端打包：</SPAN><SPAN lang=EN-US>packjage com.cxy;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">更改后所传送的类在：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">服务器端打包：</SPAN><SPAN lang=EN-US>package com..cxy;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'">客户端打包：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">package com..cxy;</SPAN></SPAN></P><img src ="http://www.blogjava.net/StarLover/aggbug/24903.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/StarLover/" target="_blank">StarLover</a> 2005-12-21 09:11 <a href="http://www.blogjava.net/StarLover/archive/2005/12/21/24903.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Applet之间的通讯</title><link>http://www.blogjava.net/StarLover/archive/2005/12/18/24471.html</link><dc:creator>StarLover</dc:creator><author>StarLover</author><pubDate>Sun, 18 Dec 2005 04:44:00 GMT</pubDate><guid>http://www.blogjava.net/StarLover/archive/2005/12/18/24471.html</guid><wfw:comment>http://www.blogjava.net/StarLover/comments/24471.html</wfw:comment><comments>http://www.blogjava.net/StarLover/archive/2005/12/18/24471.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/StarLover/comments/commentRss/24471.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/StarLover/services/trackbacks/24471.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">希望实现一个</SPAN><SPAN lang=EN-US>Applet</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">与另外一个</SPAN><SPAN lang=EN-US>Applet</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进行通讯时，必须用</SPAN><SPAN lang=EN-US>getAppletContext()</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法先取得另外一个</SPAN><SPAN lang=EN-US>Applet</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的句柄，再用</SPAN><SPAN lang=EN-US>getAplplet(name)</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法取得</SPAN><SPAN lang=EN-US>Applet</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，具体代码实例如下：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>AppletContext ac = getAppletContext();</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:line id=_x0000_s1026 style="Z-INDEX: 1; LEFT: 0px; POSITION: absolute; TEXT-ALIGN: left" to="2in,23.4pt" from="2in,7.8pt"></v:line><SPAN lang=EN-US>Applet applet = ac.getContext(“other”);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><v:line id=_x0000_s1027 style="Z-INDEX: 2; LEFT: 0px; POSITION: absolute; TEXT-ALIGN: left" to="306pt,7.8pt" from="2in,7.8pt"></v:line><v:line id=_x0000_s1028 style="Z-INDEX: 3; LEFT: 0px; POSITION: absolute; TEXT-ALIGN: left" to="306pt,93.6pt" from="306pt,7.8pt"><v:stroke endarrow="block"></v:stroke></v:line><SPAN lang=EN-US>&nbsp;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><v:line id=_x0000_s1029 style="Z-INDEX: 4; LEFT: 0px; POSITION: absolute; TEXT-ALIGN: left" to="387pt,7.8pt" from="225pt,7.8pt"></v:line><v:line id=_x0000_s1030 style="Z-INDEX: 5; LEFT: 0px; POSITION: absolute; TEXT-ALIGN: left" to="387pt,132.6pt" from="387pt,7.8pt"></v:line><SPAN lang=EN-US>TextArea text = (TextArea)applet.getComponent(2);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>Text.append(“good luck”+”\n”);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>&nbsp;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其中</SPAN><SPAN lang=EN-US>other</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是另外一个</SPAN><SPAN lang=EN-US>Applet</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的名字：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>&lt;html&gt;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;applet code = “applet.java” width=”300” height=”200” name=”other”&gt;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>&lt;/applet&gt;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>&lt;/html&gt;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><v:line id=_x0000_s1031 style="Z-INDEX: 6; LEFT: 0px; POSITION: absolute; TEXT-ALIGN: left; flip: x" to="387pt,7.8pt" from="81pt,7.8pt"></v:line><v:line id=_x0000_s1032 style="Z-INDEX: 7; LEFT: 0px; POSITION: absolute; TEXT-ALIGN: left" to="81pt,31.2pt" from="81pt,7.8pt"><v:stroke endarrow="block"></v:stroke></v:line><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US></SPAN>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">而</SPAN><SPAN lang=EN-US>getComponent(2)</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的参数“</SPAN><SPAN lang=EN-US>2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">”是指添加到</SPAN><SPAN lang=EN-US>Applet</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的组件的次序（从</SPAN><SPAN lang=EN-US>1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">开始）</SPAN><SPAN lang=EN-US>;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这样我们就能操纵另外一个</SPAN><SPAN lang=EN-US>Applet</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的组件了。</SPAN></P>
<P align=right>2005年12月18日</P><img src ="http://www.blogjava.net/StarLover/aggbug/24471.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/StarLover/" target="_blank">StarLover</a> 2005-12-18 12:44 <a href="http://www.blogjava.net/StarLover/archive/2005/12/18/24471.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>