I put together a java ChatClient and ChatServer on Max OS X Version 10.7.5 for fun with my kids. We were using Java Version 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.
When I open the HTML in Safari 6.0.2., I get no sign of errors or the applet running. In Safari, I have enable plug-ins, Java, and Javascript. Only the text in the HTML is displayed; 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. The applet is a simple guy that asks to connect via socket, then sends and receives text from any other clients including itself.
<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. You should think about a couple things here -
First, abide by HTML standards. This includes having all of your html tags and attributes in lowercase. <PascalCase>
, <camelCase>
are not standard for HTML.
Second, switch your applet tag to an object.
Thirdly, wrap all text in a block tag other than <body>
. Most popular one is <p>
meaning paragraph.
Fourthly, wrap ALL html attribute values in double quotes. example: width=200
should be width="200"
Fifthly, think about doing 2 spaced tabs when doing 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. 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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.