applet问题,找了很多论坛高手都没有人能解决!

lgzly 2003-09-12 08:48:34
我编写了一段APPLET小代码编译成功后想运行它:JAV源程序如下:
import java.applet.Applet;
public class DoNothing extends Applet
{
}
HTML代码如下:
<applet code=”DoNothing.class” heoght=”200” width=”300”>
</applet>
我的环境变量设置为:
CLASSPATH=.;C:\j2sdk1.4.2\lib\tools.jar;c:\j2sdk1.4.2\lib\dt.jar;c:\j2sdk1.4.2\bin;
PATH=c:\j2sdk1.4.2\bin
JAVA_HOME=C:\JWSDK1.4.2;
在DOS环境下我也用set命令看了一下,内容与上述三项是一样。还有什么其他原因吗?
我用APPLETVIEWER DoNothing时,出现的错误提示是:进行读取时出现I/O异常,然后就是系统找不到指定的文件。我换成APPLETVIEWER DoNothing.class后,屏幕上什么也没有。用IE游览结果却是源代码。是不是我的JVM没有运行,还是其他什么原因?这个问题困扰我好几天了我重装过JRE、还换过版本,就差没有格式化系统了。请各位高手帮忙看看,多谢了!并祝各位中秋快乐!




...全文
62 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
wb_0410 2003-09-15
  • 打赏
  • 举报
回复
微软是希望能用word编辑html,提高word与frontpage的结合,不过你可以看一下word创建的html文件,里面比单纯的html文件多了很多其他的东西。
下面是一个用word生成的html文件,里面就输入了一句话:This is a html file edited by word.

但是你可以看一下它的源文件:呵呵。
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="word.files/filelist.xml">
<title>This is a html file edited by word</title>
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author>wangbo</o:Author>
<o:LastAuthor>wangbo</o:LastAuthor>
<o:Revision>1</o:Revision>
<o:TotalTime>1</o:TotalTime>
<o:Created>2003-09-15T05:42:00Z</o:Created>
<o:LastSaved>2003-09-15T05:43:00Z</o:LastSaved>
<o:Pages>1</o:Pages>
<o:Words>5</o:Words>
<o:Characters>31</o:Characters>
<o:Company>runway</o:Company>
<o:Lines>1</o:Lines>
<o:Paragraphs>1</o:Paragraphs>
<o:CharactersWithSpaces>35</o:CharactersWithSpaces>
<o:Version>10.2625</o:Version>
</o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:GrammarState>Clean</w:GrammarState>
<w:PunctuationKerning/>
<w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
<w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
<w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
<w:Compatibility>
<w:SpaceForUL/>
<w:BalanceSingleByteDoubleByteWidth/>
<w:DoNotLeaveBackslashAlone/>
<w:ULTrailSpace/>
<w:DoNotExpandShiftReturn/>
<w:AdjustLineHeightInTable/>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:UseFELayout/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:42.55pt;
mso-footer-margin:49.6pt;
mso-paper-source:0;
layout-grid:15.6pt;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]-->
</head>

<body lang=ZH-CN style='tab-interval:21.0pt;text-justify-trim:punctuation'>

<div class=Section1 style='layout-grid:15.6pt'>

<p class=MsoNormal><span lang=EN-US>This is a html file edited by word.</span></p>

</div>

</body>

</html>
lgzly 2003-09-13
  • 打赏
  • 举报
回复
问题解决了,谢谢各位!我是一个新手问题的描述不是很清楚,让各位高手疑惑,实在是不好意思!因为我的HTML文件是用WORD编写的,后来我在FONTPAGE里重新输入后,运行就一点问题也没有。我也不明白这是什么原因,多谢大家!
lgzly 2003-09-12
  • 打赏
  • 举报
回复
源程序改为如下:
import java.applet.Applet;
public class DoNothing extends Applet
{
public void init(){ };
}
怎样去掉APPLET里面的有关本地文件操作代码?能否详细描述一下,因我是个初学者刚学没几天,多谢了!
pxboy 2003-09-12
  • 打赏
  • 举报
回复
IE打开的怎么可能是源程序?是HTML源程序?那肯定是Applet标记没写好啦
lgzly 2003-09-12
  • 打赏
  • 举报
回复
jdb也重装了甚至换过版本还是不行
sharewarer 2003-09-12
  • 打赏
  • 举报
回复
有可能jdk有问题,可以重装
KevinListening 2003-09-12
  • 打赏
  • 举报
回复
是你的Applet里面有Java.io.*里面的操作,也就是对本地文件的操作,这在Web上是不允许的。
把你的Applet里面的有关本地文件操作代码去掉,然后重新编译,即可。
lgzly 2003-09-12
  • 打赏
  • 举报
回复
上面的小错误我都改过来了,也按照你们的指教改过来了,可用appletviewer donothing.html运行时还是这样什么提示也没有.用IE打开的却是源程序。环境变量也改过来了!
pqds 2003-09-12
  • 打赏
  • 举报
回复
init()
chenxb1980 2003-09-12
  • 打赏
  • 举报
回复
public void init(){ }

nic2008 2003-09-12
  • 打赏
  • 举报
回复
环境变量应该这样设置吧:
CLASSPATH=C:\j2sdk1.4.2\lib\tools.jar;.;c:\j2sdk1.4.2\lib\dt.jar;

你少了一个最重要的点!!!
cadwolf 2003-09-12
  • 打赏
  • 举报
回复
老兄,看看书再 问好吗?
casemy 2003-09-12
  • 打赏
  • 举报
回复
init()这个函数再applet里必须覆写
casemy 2003-09-12
  • 打赏
  • 举报
回复
没有初始化
import java.applet.Applet;

public class DoNothing extends Applet
{
public void init(){
}
}
阎罗 2003-09-12
  • 打赏
  • 举报
回复
c:\j2sdk1.4.2\bin; 不应该放在classpath里面,还有java_home里面应该是c:\j2sdk1.4.2;
wangyanqiu 2003-09-12
  • 打赏
  • 举报
回复


应该是appletviewer donothig.html或者......htm

swinging 2003-09-12
  • 打赏
  • 举报
回复
还有你的题目太夸张了。
sweat y
swinging 2003-09-12
  • 打赏
  • 举报
回复
我建议你拿个工具生成一个简单的APPLET,然后观察下它生成的所有文件和代码。
比如VAJ。
或者就拿 wb_0410(天煞) 的代码比较就可以了。
还有,最大可能是你的HTML不对。
lgzly 2003-09-12
  • 打赏
  • 举报
回复
多谢!马上重新整理
wb_0410 2003-09-12
  • 打赏
  • 举报
回复
你的问题在别人那里不能重现,大家就不容易帮你搞定,你把所有的东西重新发表一遍。
象我这样。
================================
=源文件:myapplet\MyApplet.java=
================================
package myapplet;
import java.applet.*;
public class MyApplet extends Applet {
public MyApplet() {
}
public void init() {
}
}
=========================
=html文件:MyApplet.html=
=========================
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>
HTML Test Page
</title>
</head>
<body>
myapplet.MyApplet will appear below in a Java enabled browser.<br>
<applet
codebase = "."
code = "myapplet.MyApplet.class"
name = "TestApplet"
width = "400"
height = "300"
hspace = "0"
vspace = "0"
align = "middle"
>
</applet>
</body>
</html>
==========
=目录结构=
==========
src--
|__myapplet--
|__MyApplet.java
classes--
|__myapplet--
| |__MyApplet.class
|
|__MyApplet.html

顺便检查你的ie中设置:在高级选项中,是否使用了正确的jre解释applet。

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧