Topic: 一个运行Applet的错误

  Print this page

1.一个运行Applet的错误 Copy to clipboard
Posted by: 流水野云
Posted on: 2005-10-06 21:26

我在运行APPLET时提示以下错误:
载入:找不到AppletInOut.class

其实我已经生成了AppletInOut.class在我的专门装Java程序的文件夹里!D:\java\AppletInOut.class
请各路高手指点迷津!!!

2.Re:一个运行Applet的错误 [Re: 流水野云] Copy to clipboard
Posted by: YuLimin
Posted on: 2005-10-06 22:50

JVM的版本是什么?

编译时用javac -target 1.1 AppletInOut.java

3.Re:一个运行Applet的错误 [Re: 流水野云] Copy to clipboard
Posted by: 流水野云
Posted on: 2005-10-07 02:02

还是不行,提示:
不能找到该文件!can't read target1.1appletinout.java
我用的版本是J2sdk1.4.2_05的!

4.Re:一个运行Applet的错误 [Re: 流水野云] Copy to clipboard
Posted by: billchang
Posted on: 2005-10-07 09:37

是不是classpath设的不对,在Applet中有没有package语句?我没遇到过你这样的错误,我只遇到过applet无法运行的错误,希望能帮你。

5.Re:一个运行Applet的错误 [Re: 流水野云] Copy to clipboard
Posted by: YuLimin
Posted on: 2005-10-07 10:43

1、My.java文件内容:

import java.awt.Graphics;
import java.applet.Applet;
public class My extends Applet
{
public String s;
public void init()
{
s=new String("Hello World");
}
public void paint(Graphics g)
{
g.drawString(s,25,25);
}
}


2、编译时加上开关条件
javac -target 1.1 My.java

3、My.html
<HTML>
<HEAD>
<TITLE>我的第一个Applet程序</TITLE>
</HEAD>
<BODY>
<APPLET CODE="My.class" WIDTH=200 HEIGHT=100>
</APPLET>
</BODY>
</HTML>

4、查看效果AppletViewer My.html

6.Re:一个运行Applet的错误 [Re: 流水野云] Copy to clipboard
Posted by: 流水野云
Posted on: 2005-10-07 17:08

实在是没办法了!
请问到底那个classpath怎么设啊?
是设为生成的.class文件的路径:.;D:\java;D:\java\classes

还是设为安装路径:.;C:\j2sdk1.4.2_05\lib\dt.jar;C:\j2sdk1.4.2_05\lib\tools.jar

请各路高手指点迷津!!!!!!

7.Re:一个运行Applet的错误 [Re: 流水野云] Copy to clipboard
Posted by: why
Posted on: 2005-10-07 20:42

DON'T double-post!
DON'T!!!

Sad
Sad

http://www.cjsdn.net/post/view?bid=1&id=158325 is locked and will be removed!

8.Re:一个运行Applet的错误 [Re: 流水野云] Copy to clipboard
Posted by: 流水野云
Posted on: 2005-10-07 22:31

Excuse me,what means about the double-post?

9.Re:一个运行Applet的错误 [Re: 流水野云] Copy to clipboard
Posted by: why
Posted on: 2005-10-07 23:42

流水野云 wrote:
Excuse me,what means about the double-post?

一帖兩發 以至 一帖多發
i.e. this post is almost the same as http://www.cjsdn.net/post/view?bid=1&id=158325

10.Re:一个运行Applet的错误 [Re: 流水野云] Copy to clipboard
Posted by: billchang
Posted on: 2005-10-08 20:49

流水野云你可以把你的代码粘上来让大家看看,也许会对你有帮助。

11.Re:一个运行Applet的错误 [Re: 流水野云] Copy to clipboard
Posted by: 流水野云
Posted on: 2005-10-08 22:54

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class AppletInOut extends Applet implements ActionListener
{
Label prompt;
TextField input, output;


public void init(){
prompt = new Label("Please input your name:");
input = new TextField(6);
output = new TextField(20);
add(prompt);
add(input);
add(output);
input.addActionListener(this);
}


public void actionPerformed(ActionEvent e){
  
output.setText(input.getText() + ",Welcome to you! ");

}

}

HTML是:
<HTML>
<HEAD>
<TITLE>  AN Applet </TITLE>
</HEAD>
<APPLET CODE = " AppletInOut.class " width = 300 height = 160>
</APPLET>
</BODY>
</HTML>
请大家帮帮忙!谢谢了!

12.Re:一个运行Applet的错误 [Re: 流水野云] Copy to clipboard
Posted by: verwa
Posted on: 2005-10-08 23:25

在这行加()就ok!
input = new TextField();


163kB bmp file removed, please DON'T use bmp file.
In addition, check "Embed (only JPG, GIF and PNG images,SWF flash file)" to show image.


13.Re:一个运行Applet的错误 [Re: 流水野云] Copy to clipboard
Posted by: verwa
Posted on: 2005-10-09 23:37

不好意思,没注意图片格式。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923