简体   繁体   English

从HTML运行Applet的迹象

[英]No Sign of Applet Running from HTML

I put together a java ChatClient and ChatServer on Max OS X Version 10.7.5 for fun with my kids. 我在Max OS X版本10.7.5上组合了一个Java ChatClient和ChatServer,以与孩子们一起玩乐。 We were using Java Version Java(TM) SE Runtime Environment (build 1.7.0_04-b21) . 我们正在使用Java版本Java(TM) SE Runtime Environment (build 1.7.0_04-b21) It runs great from the Terminal. 它从终端运行得很好。 Also, we'd like to able to run it from Eclipse by passing in parameters. 另外,我们希望能够通过传入参数从Eclipse运行它。

When I open the HTML in Safari 6.0.2., I get no sign of errors or the applet running. 当我在Safari 6.0.2。中打开HTML时,没有任何错误迹象或applet正在运行。 In Safari, I have enable plug-ins, Java, and Javascript. 在Safari中,我启用了插件,Java和Javascript。 Only the text in the HTML is displayed; 仅显示HTML中的文本; the applet does not seem to run or anything. 小程序似乎没有运行或任何东西。

Once I get this working, I would like to package in a JAR file and sign it so I can create a socket to my server. 一旦开始运行,我想打包成一个JAR文件并对其进行签名,以便为我的服务器创建一个套接字。 The applet is a simple guy that asks to connect via socket, then sends and receives text from any other clients including itself. applet是一个简单的家伙,它要求通过套接字进行连接,然后从任何其他客户端(包括其自身)发送和接收文本。

<Html>
    <Head>
        <Title>Java Example</Title>
    </Head>

    <Body>
        This is my page<br>
        Below you see an applet<br>
        <br>
        <Applet Code="ChatClient" width=200 Height=100>
            <PARAM name="host" value="xxxxx-iMac.local">
            <PARAM name="port" value="4445">
        </Applet>
        after Applet
    </Body>
</Html> 

In section 13.4, the APPLET tag in HTML is deprecated, and it's successor is the <object> element. 在13.4节中,不赞成使用HTML中的APPLET标记,它的后继元素是<object>元素。 You should think about a couple things here - 您应该在这里考虑几件事-

First, abide by HTML standards. 首先,遵守HTML标准。 This includes having all of your html tags and attributes in lowercase. 这包括将所有html标记和属性都转换为小写。 <PascalCase> , <camelCase> are not standard for HTML. <PascalCase><camelCase>不是HTML的标准配置。

Second, switch your applet tag to an object. 其次,将applet标记切换到一个对象。

Thirdly, wrap all text in a block tag other than <body> . 第三,将所有文本包装在<body>以外的块标记中。 Most popular one is <p> meaning paragraph. 最受欢迎的是<p>意思是段落。

Fourthly, wrap ALL html attribute values in double quotes. 第四,将所有html属性值都用双引号引起来。 example: width=200 should be width="200" 例如: width=200应该为width="200"

Fifthly, think about doing 2 spaced tabs when doing html. 第五,考虑在做html时做两个间隔的制表符。 it's much cleaner :) 它更干净:)

I could go on, but i could be here forever. 我可以继续,但我可以永远在这里。 Bottom line is, follow standards . 底线是, 遵循标准

But to answer your question: In the specification, it looks like it expects the file name. 但是要回答您的问题:在规范中,它看起来像期望的文件名。 this includes ".class" at the end. 末尾包括“ .class”。 Try, 尝试,

<html>
  <head>
    <title>Java Applet Example</title>
  </head>

  <body>
    <div id="container">
      <applet code="ChatClient.class" width="200" height="100">
        <param name="host" value="xxxxx-iMac.local" />
        <param name="port" value="4445" />
      </applet>
    </div>
  </body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM