🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.program
Article #2488

Java Q&A (GB��) (��)

#2488
From: �ڰ�֮��
Date: Sat, 20 Dec 1997 00:00
701 lines
16458 bytes
JAVA Q&A����

�����ϲ���Ӵ................. 




��һ�ʡ�



:       ������javac����õ�class�Dz���һ��Ҫ����java\lib�²�����java��run

:       �ұ�������java�����ѽ���һ����Ŀ¼�����Լ�д�õ�һЩ��ʽ,

:       ����ÿ�α������Ҫ��java��runʱ������֪�Ҳ�����һ��class,                       

:       �����Ұ��ұ�����class copy ��libĿ¼�¾���ִ��,

:       �Dz���һ��Ҫ�����鷳��?Ϊʲ��java��"������"����Ŀ¼�µ�class��?

:       ps:�ҵ�Ŀ¼����:

:                       c:\java+----bin

:                                 +----lib----�ҵ�classpath�趨����     

:                                 +----include

: +----exercise---�������ִ��java,*.class,*.javaҲ����

:       and.�ҽ�bin����path��...

:       �




        ֻҪ Set CLASSPATH ������������÷ֺŷָ���� Path



        Set CLASSPATH = .... ; ...... ; ......










�ڶ��ʡ�



: �ҵij�ʽ�ڱ����ʱ����������µ�ѶϢ:

: failed to read:C:\JAVA\BIN\...\lib\javac.propeties

: Motorcycle.java:22:error message'toplevel.expected' not found

: Motorcycle Nsr;

: ^

: ��ΪѧУû��Java�Ŀγ�,���������Լ�����ѧ��,���Java�Ĺ���������

: �����������һ�����д?ϣ���Ҷ��ָ��....

: �ҽ���ʽ�븽�ڵ���,ϣ���ܹ��õ���ı������,лл!

: package TrafficTools;  //���һ����Ϊ TrafficTools��package

:                      //��������һ��һ��Ҫimport�κ������?

:                       (����:java.applet.Applet)//

                  ��һ�� �������Ҫ������� but default import java.lang.* 



:                     //��Ҫ����һ�������沢����Motorcycleȥimplements��?

                  ��һ�� ��������Ҫʱ



:

: Motorcycle Nsr; //���NsrΪMotorcycle�������,���̳�Motorcycle

: Nsr=new Motorcycle();  //����Nsr���

: Nsr.Count();  //����Nsr���ʹ�� Count() ��һ��method

  ��������Ҫд�� Motorcycle class �� main Function �� ��Ϊ�ⲻ���� C++



  class Motocycle {

        

        // һ�� Java Application (not Applet) һ��Ҫ�е� function

        public static void main(String Args[]) { // ��ʽ�����

            Motorcycle Nsr;

            Nsr = new Motorcycle();

            Nsr.Count;

        }

  }










�����ʡ�



: �����뽫���applet����homepage��,��ҲҪд main function��??

: main function�����ܷ���homepage�ϰ�....



  �԰� !! application ����Ҫ�� !! applet ���� init() �� Motorcycle Ҫ�̳�

  applet . ��� new Motorcycle Object ������ Browser ����  



: ����һ�������� Motorcycle Nsr;

:                Nsr = new Motorcycle();

:                Nsr. Count();

: ������һ��Ҫд��Motorcycle����������?

: ��ָ��,лл!

  Yes ... 

  Java û�� Gobal ���κζ��� 










�����ʡ�



> : ��˵CGI��ʽ�������κγ�ʽ������д��������ɲ�������Java��д�ء�

> : �����ԡ�����

> : Ҫ���Ǹ�class��method��ȡ��client�����������ء���ͨ����stdin��Ҫ����д��

> : ��client��Ҫ��κ���server��Java CGI��ʽ����
 : action="http://xxx.dom.???.tw/cgi-bin/___________">

> �ٲ���һ�¡�����win95�¡�������symbolic link.



    1. CGI ������ Java д. ��� Java ��ʽ�� Application ��� Applet.



    2. ͨ�������ʽ����������� code:



       import java.io.*;

       ...

       DataInputStream instring = new DataInputStream(System.in);

       PrintStream outstring = new PrintStream(System.out);

       string HTMLout;

       while ((input = instring.readLine()) != null) {

           // Do what the CGI program should do

           // then, write output using outstring.println(HTMLout);

       }

       outstring.close();

       ...



    3. ��� Client ����κ���, ����һ������. �����

       ACTION="http://xxx.dom.???.tw/cgi-bin/xxx.class"

       ��� Web server ֱ��֧Ԯִ�� Java ��ʽ, ����, ��������.

       Java ��ʽ������ interpreter ִ�е�. ���ܵ�һ����ͨ����,

       ����ִ��ij������ shell �ij�ʽ (�� *.bat, ������ Win95),

       ����ִ�� java xxx.class. ��û���Թ��Ƿ����?



    4. ����Ҫ symbolic link.










�����ʡ�



>: :    ����һ��Ҫ�����TextField����������?

>: :    лл

>: Java ��Ԫ�� Unicode,���� big5 ����ܲ���.

>  лл<

>  ���������TextField��AppletҪ�����

>  Webʹ��������������?



Ŀǰ��֪��ֻ����copy & paste ����big5������ !










�����ʡ�



>�����ѧjava

�����������վ̨:http://atmwww.cm.nctu.edu.tw/~duann/javascript/script.html










�����ʡ�



����һ��ѧϰ Java script ��վ

http://www.essex1.com/people/timothy/js-index.htm



������ clock,banner,timer,color �� java script

����!!










�ڰ��ʡ�



: I have a problem about use a Applet to communicate with web server's CGI 

: program. Explan as below:

�Ҳ�ԭ����



:      try{

:        URL sortURL=new URL("http://my.address/cgi-bin/test.sh");

                                     ^^^^^^^^^^ ��߲���hard-coded

                            һ��Ҫ��getCodeBase().getHost()

                           ��ΪSecurityManager��ȥ����hostname

                           �뺬�����applet��homepage��URL��

                           ��hostname���ִ��ıȶ�,�����hostname

                           ��IP address�Ƿ��Ӧ��ͬһ̨����,ֻҪ��һ��

                           �ͻ���SecurityException,���ѶϢӦ������

                           browser�����status����

   

:        URLConnection connection= sortURL.openConnection();

:        PrintStream outStream=new PrintStream(connection.getOutputStream());

:        outStream.println("my data to send");

:        outStream.close();

:      }

:      catch........I have a problem about use a Applet to communicate with web server's CGI 

 








�ھ��ʡ�



:    С���и��ɻ����

:   ��:

:      imports java.awt.Graphics

:     java.awt�Ǹ�PACKAGE

:     �����Graphics��Class

:      ��� m...û����,�������

:    ��...��:

:     System.out.println("...");

:   System.out�DZ���??

:     ��������Method?? ����...д��javaһ���ڼ�,ÿ��д���������޷�����..

:    System�����֪�Ǻη���ʥ?? ��package ,��class ����variable

:    ���������Ժ�.. ��˭��˵˵System������implement ������?

:    bye~

���:

�������������(�������!):



���г� System ��� class:

public  final  class  java.lang.System extends  java.lang.Object  

{

        // Fields

    public static PrintStream err;      ��

    public static InputStream in;       ��

    public static PrintStream out;      ��



        // Methods

    public static void  ��

        arraycopy(Object  src, int  src_position,

                Object  dst, int  dst_position, int  length);

    public static long currentTimeMillis();     ��

    public static void exit(int  status);       ��

    public static void gc();    ��

    public static Properties getProperties();   ��

    public static String getProperty(String  key);      ��

    public static String getProperty(String  key, String  def); ��

    public static SecurityManager getSecurityManager(); ��

    public static void load(String  filename);  ��

    public static void loadLibrary(String  libname);    ��

    public static void runFinalization();       ��

    public static void setProperties(Properties  props);        ��

    public static void setSecurityManager(SecurityManager  s);  ��

}

����Կ��� in �� out ���� class variables,����Ҫʹ���������ȫ��,�� System.in

�� in �� out(����err) ���� reference,in ��һ�� InputStream ����� reference,

out ��һ�� PrintStream ����� reference,�� System �� class �� load ����ʽ��ʱ,

����Զ�����һ�� InputStream(PrintStream) �����,Ȼ����� in(out) ��� variable,

���� in(out) �Ϳ���ʹ�� InputStream(PrintStream) ����� instance methods.



����֪�����?












��ʮ�ʡ�



:  �����ѱ���õ� CGI ��ʽ�Ƿ�һ��Ҫ���� server �˵�����Ŀ¼��???

:  ���û����·����(����) ����β���?

:  PS:�� VB ׫д

> NCSA���httpd��������CGI��ʽ��,*.cgi�ķ�ʽ���ڲ�ִ�ж�ط��� server

> �˵�����Ŀ¼��,����������Կ���,����еĻ��������㻹�������

> ������װһ��server���ܿ��Խ��.

> �����ɹ���������������ɵ�!!

����Ļ��������а취�����ֻ��һЩunix�ϵ�ָ������������trouble

���ȿɼܸ�ncsa��whttpd (��֪����95��???)

����VB�Ļ����ҵ������ǽ���compiler��exe���c:\httpd\cgi-winĿ¼��

����perl�Ļ����ͼܸ�perl5��c:\usr\local\lib\perl�¡���ȻҪ��pif��

��httpd.cnf�������޸ġ�Ȼ�Ὣ*.pl����c:\httpd\cgi-dosĿ¼��

��http://127.0.0.1/cgi-dos/*.pl �� http://127.0.0.1/cgi-win/*.exe

�Ϳ��ڵ���ִ��cgi��ʽ��test ok֮����upload��server�С���ʡǮ˵��

�����д?��ָ�̡�

*�ԡ�lynx 2.5 Ҳ���Ե����� CGI ��ʽ�����谲װ httpd��

*��95��nt��, �����Լ���һ�������ip

        �ټӸ�վ, Ȼ��http���Ǹ�ip�Ϳ�����










��ʮһ�ʡ�





: :  Ҳ����˵Ҫ��ΰ�: *.class ===> *.java

: :                           ת��

: Ŀǰ������.



���޶��Ͽ���



    http://web.inter.nl.net/users/H.P.van.Vliet/mocha.htm










��ʮ���ʡ�



:       ��������getGraphicsʱ

:       ��Ҫ��Ҫoff-screen ��image

:       �������image����off-screen ���ء�����

��!off-screen��˵�㲻�Ǵӵ���ץ������image

���Ǵ�createImage(������������˻�Ҫ����)���method

��������Image�����ϼ���֮������˵��?










��ʮ���ʡ�



:         I have a problem about clipRect(..),a member function of 

:         class Graphics..

:         In my applet,I must update two parts of Rectangle when a

:         paint event is driven.So I wrote the program as follow..

:                 public void paint(Graphics g){

:                         :

:                      g.clipRect(..);    // first part needs to update

:                         :

:                      g.clipRect(..);    // second part needs to update  

:                         :

:                 }

:         But the result was so strange.Only the first part could be 

:         updated.Second part would not be active.        

:         Why? Who can tell my how to solve the problem? Thanks!



This method will set a clipping rectangle for this graphics context.

The resulting clipping area is the intersection of the current clipping area

                                   ~~~~~~~~~~~~

and the specified rectangle.

Thus, after the first calling of this method, the "current" clipping area

would be the first rectangle part, and if the second rectangle part were

a standalone one(that is, without intersecting in first part), then the

"current" clipping area might be EMPTY!(becouse no intersection) That is 

why the second action was fail.

In my opinion, you can try to put a code between these two methods calling,

such as:

         :

     g.clipRect(..);

         :

     g.clipRect(the whole graphic(image) area); //new added line

         :

     g.clipRect(..);

         :



**Thanks for your help.I have made an experiment about you 

        suggestion.I found somethings right,but still somethings 

        wrong what you wrote above!



        In your opinions,the intersaction effect of clipped areas 

        was correct.But the method to reset the clipped area you 

        suggested was wrong.Clipped area could not be reseted by 

        the method of

                g.clipRect(full area of graphics);      or

                g.clipRect(0,0,0,0);

        in my experiment.



        But

        I have a new solution about this problem.This solution use 

        the method,Graphics::create(),to get a new copy of current 

        graphics context. You can re-clip the demanded area in the 

        new Graphics object & then do what you want to do.By this 

        way, you can avoid the intersaction effect of clipped areas.






            ����������������? �����κν��顡��д���Ÿ����ǰ�!! С���ᾡ�������ܵ��ġ�

                        Copyright (c) 1996 BluesTown Music & Internet Centre. 
                           Last modified: Wednesday, August 07 1996 01:55 

--

�� ��Դ:���ɰ��ļ�BBSվ bbs.njtu.edu.cn��[IP: 202.112.145.26]
Technical Details
Message-ID: <3MCZgg$tvC@bbs.njtu.edu.cn>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: Chinese,GB
X-Google-Thread: fc86e,7c628eee10119be6,start
X-Google-Attributes: gidfc86e,public
From: Uni.bbs@bbs.njtu.edu.cn (�ڰ�֮��)
Subject: Java Q&A (GB��) (��)
Date: 1997/12/20
Message-ID: <3MCZgg$tvC@bbs.njtu.edu.cn>
X-Deja-AN: 309545420
X-Filename: Programming/M.882606858.A
Organization: ��������ɰ��ļ�
Newsgroups: cn.bbs.comp.program