Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javaÓëÍøÂç


1 ÍøÂçͨÐŵı¾ÖÊÊǽø³Ì¼äͨÐÅ¡£   
2 TcpЭÒéºÍUDPЭÒé
TCP£º¿ªÏú´ó£¬ÓÃÓÚ¿É¿¿ÐÔÒªÇó¸ßµÄ³¡ºÏ¡£
TCPµÄ¹ý³ÌÏ൱ÓÚ´òµç»°µÄ¹ý³Ì
UDP£ºÓÃÔÚ¶ÔʵʱÐÔÒªÇó±È½Ï¸ßµÄ³¡ºÏ¡£
UDPµÄ¹ý³ÌÏ൱ÓÚдÐŵĹý³Ì¡£
×¢Ò⣺socketÊÇÌ×½Ó×Ö£¬ipºÍport£¨¶Ë¿ÚºÅ 0~65535¸ö¶Ë¿Ú£¬Ò»¸ö¶Ë¿ÚÖ»ÄÜÓÐÒ»¸ö½ø³Ì£©
3£¬    TCPͨÐÅ»úÖÆ£¬tcpÊÇÃæÏòÁ¬½ÓµÄ£¬ÊµÏÖ¶àÏ̵߳ķ½·¨ÓÐÈý¸ö
¢Ù Ϊÿ¸ö¿Í»§·ÖÅäÒ»¸ö¹¤×÷Ï̡߳£
¢Ú  ´´½¨Ò»¸öÏ̳߳أ¬ÓÉÆäÖеŤ×÷Ïß³ÌÀ´Îª¿Í»§·þÎñ¡£
¢Û  ÀûÓÃJDKµÄJavaÀà¿âÖÐÏֳɵÄÏ̳߳أ¬ÓÉËüµÄ¹¤×÷Ïß³ÌÀ´Îª¿Í»§·þÎñ¡£
ÏÂÃæÒÔΪÿ¸ö¿Í»§·ÖÅäÒ»¸ö¹¤×÷Ïß³ÌÀ´ÊµÏÖ¶àÏß³Ì
ÔÚ·þÎñ¶Ë
import java.net.*;
import java.io.*;
public class TCPServer2 {
   public static void main(String[] args) throws Exception{
      ServerSocket ss=new ServerSocket(9000);//¶Ë¿ÚºÅ
      while(true){
           Socket s=ss.accept();//Á¬½Ó¼àÌý¿Í»§¶Ë
           System.out.println(s.getInetAddress());
           Thread t=new ServerThread(s);//ʵÏÖ¶àÏß³ÌÁ¬½Ó
           t.start();
      }
   }
}
class ServerThread extends Thread{//·ÖÅäÏß³Ì
   Socket s;
   public ServerThread(Socket s){
      this.s=s;
   }
public void run(){
   try {
      OutputStream os=s.getOutputStream();//ÔÚÍøÂçÖлñÈ¡Êä³öÁ÷
      PrintWriter out=new PrintWriter(os);
      for(int i=1;i<=30;i++){
      out.println("Hello "+i);//ͨ¹ýÍøÂç·¢ÏûÏ¢¸ø¿Í»§¶Ë
      out.flush();
      Thread.sleep(1000);
           }
      } catch (Exception


Ïà¹ØÎĵµ£º

¡¶javaÓïÑÔ³ÌÐòÉè¼Æ£¨Ò»£©¡·2009Äê×Ôѧ¿¼ÊÔ´ó¸ÙµÚ10ÕÂ

µÚ10Õ ÍøÂçÓëÊý¾Ý¿â±à³Ì»ù´¡
(Ò»)¿Î³ÌÄÚÈÝ
10.1 JavaÍøÂç±à³Ì»ù´¡
10.1.1 IPµØÖ·ºÍInetAddressÀà
10.1.2ͳһ×ÊÔ´¶¨Î»·ûURL
10.1.3¿Í»§»ú/·þÎñÆ÷ģʽ
l0.2 JavaÊý¾Ý¿â±à³Ì»ù´¡
10.2.1 Java³ÌÐòÓëÊý¾Ý¿âÁ¬½Ó
10.2.2¼¸¸öÖØÒªµÄÀàºÍ½Ó¿Ú
10.2.3Êý¾Ý¿â²éѯ
10.2.4Êý¾Ý¿â¸üÐÂ
(¶þ)ѧϰĿµÄÓëÒªÇó
±¾Õ½éÉÜJavaÍøÂç± ......

javaʱÇø½â¾ö·½°¸

 tomcatÆô¶¯web·þÎñµÄʱºò×ÜÊÇ»áÓÐ8СʱµÄʱ²î,
×ÁÄ¥Á˺þÃ,×î¼òµ¥µÄ°ì·¨¾ÍÊÇ
ÕÒµ½Îļþ¼Ðjdk1.6.0_07\jre\lib\zi\Etc
ÕâÀï±ß¶¼ÊÇһЩʱÇøÎļþGTM+1,GTM+2,GTM+3....
±¸·ÝÒ»·ÝEtc
¿½±´N·ÝGTM+8Îļþ(ÖйúµÄʱÇøÊÇGTM+8)
°ÑGMT+8ÎļþÃû¸Ä³ÉGTM+1,GTM+2,GTM+3....
¸²¸ÇµôÔ­À´µÄEtcÀï±ßµÄÎļþ
ÖØÆôtomcatÎÊÌâ½â¾ö ......

Jconsole ºÍ jps ÎÞ·¨ÏÔʾ±¾µØ Java ½ø³ÌÁбí

Ç°Ò»ÕóÔÚ¹«Ë¾ÀïʹÓà jconsle ʱһÇÐÕý³££¬È»¶øÔÚ¼ÒÖеĻúÆ÷ÉÏÈ´³öÏÖÁ˱êÌâËùʾµÄÎÊÌ⣺
jconsole ºÍ jps ÎÞ·¨ÏÔʾ±¾µØ Java ½ø³ÌÁÐ±í¡£
µ±Ê±Ö±½ÓÀûÓà -Dcom.sun.management.jmxremote.port=port Æô¶¯Ä¿±ê java ½ø³Ì£¬²¢ÔÚ jconsole ÖÐͨ¹ý localhost:port ·½Ê½³É¹¦Á¬½ÓÉÏÄ¿±ê java ½ø³Ì¡£ÓÐÁËÕâ¸ö work around Ö®ºó£¬¶ÔÕ ......

JavaÐéÄâ»ú¼¸¸öÃüÁîÐвÎÊý˵Ã÷

Ò»¡¢ÔËÐÐclassÎļþ
Ö´Ðдømain·½·¨µÄclassÎļþ£¬ÃüÁîÐÐΪ£º
java <CLASSÎļþÃû>
×¢Ò⣺CLASSÎļþÃû²»Òª´øÎļþºó׺.class
ÀýÈ磺
java Test
Èç¹ûÖ´ÐеÄclassÎļþÊÇ´ø°üµÄ£¬¼´ÔÚÀàÎļþÖÐʹÓÃÁË£º
package <°üÃû>
ÄÇÓ¦¸ÃÔÚ°üµÄ»ù·¾¶ÏÂÖ´ÐУ¬ÃüÁîÐÐΪ£º
java <°üÃû>.CLASSÎļþ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ