Discussion:
[JSP ]JSP頁面載入Applet的問題
(时间太久无法回复)
kerro
2007-03-21 15:09:26 UTC
Permalink
最近開始學習用Applet,書本上的範例都可以成功載入
可是改用自己的程式載入就會失敗,查詢主控台的結果說是無法創設class檔
可是java程式本身我已經編譯過了,google查詢錯誤訊息也查不到相關資料
想請各位指點個方向,感謝
附上錯誤訊息:
載入︰無法創設 readxml.class。
java.lang.InstantiationException: readxml
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-4" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.132.58.82
P***@ptt.cc
2007-03-24 14:00:53 UTC
Permalink
�ھڸӨҥ~������

���G�O�Anew�F�Y�Ӥ����άO���H���O

�i���nnew�@�ӹ��@�����O�N�i�H�ѨM�a

�ոլ� �ڤ��T�w�o�ӵ��ץi�H��U�A

�� �ޭz�mkerro (kerro)�n���ʨ��G
: �̪��}�l�Dzߥ�Applet�A�ѥ��W���d�ҳ��i�H���\���J
: �i�O���Φۤv���{�����J�N�|���ѡA�d�ߥD���x�����G���O�L�k�г]class��
: �i�Ojava�{�������ڤw�g�sĶ�L�F�Agoogle�d�߿��~�T���]�d������������
: �Q�ЦU�����I�Ӥ��V�A�P��
: ���W���~�T��:
: ���J�J�L�k�г] readxml.class�C
: java.lang.InstantiationException: readxml
: at java.lang.Class.newInstance0(Unknown Source)
: at java.lang.Class.newInstance(Unknown Source)
: at sun.applet.AppletPanel.createApplet(Unknown Source)
: at sun.plugin.AppletViewer.createApplet(Unknown Source)
: at sun.applet.AppletPanel.runLoader(Unknown Source)
: at sun.applet.AppletPanel.run(Unknown Source)
: at java.lang.Thread.run(Unknown Source)
: Exception in thread "Thread-4" java.lang.NullPointerException
: at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
: at sun.plugin.AppletViewer.showAppletException(Unknown Source)
: at sun.applet.AppletPanel.runLoader(Unknown Source)
: at sun.applet.AppletPanel.run(Unknown Source)
: at java.lang.Thread.run(Unknown Source)

--
 .�D . . �D . �D. .  ���j�P�ϪO���򨫡H
 . �d �D . . .  .  ���ͬ��T���] �ͬ�, �T��, �߱�
  ���m     �� TaiwanPlaza �x�W �U�x�W�C���a
   �m �c�o   �k   �� TaipeiCity �x�W �U�x�_
  �m   �o  ���g�g�� �n   �� Datong �_�� ���j�P�ϪO
  �m   �o     �n    �j�P�ϪO�w���A 

--
�� �o�H��: ���������~�{(ptt.cc)
�� From: 220.133.82.218
骨頭
2007-03-24 15:02:00 UTC
Permalink
※ 引述《kerro (kerro)》之銘言:
: 最近開始學習用Applet,書本上的範例都可以成功載入
: 可是改用自己的程式載入就會失敗,查詢主控台的結果說是無法創設class檔
: 可是java程式本身我已經編譯過了,google查詢錯誤訊息也查不到相關資料
: 想請各位指點個方向,感謝
: 附上錯誤訊息:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/InstantiationException.html

這算是執行期error,你所載入的class在取得實體的時候出了error,


比方說像這個
Class.forName("java.io.InputStream").newInstance();
因為InputStream是abstract class,無法產生實體。



身為一個程式人應該要了解,
就算能夠編譯class,也不能保證程式在執行時絕對完善。

比方說 System.out.println(5/0);
就是個編譯可過,runtime會被擋回來的例子。


--
另外,『如果』你希望讀檔的話,
applet環境預設是不能做IO操作的。(安全性問題)

--
I am a person, and I am always thinking .
Thinking in love , Thinking in life ,
Thinking in why , Thinking in worth.
I can't believe any of what ,
I am just thinking then thinking ,
but worst of all , most of mine is thinking not actioning...

--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.134.27.68

Loading...