0

I've got a Java applet that will only work correctly one time on any browser. I've run through the java console and cleared the class cache, refreshed the page, reloaded the browser, emptied the browser cache and I can only get this applet to work once. I've tried chrome, IE10 and FireFox. any help is greatly appreciated.

here is the applet code:

import java.applet.*;
import java.awt.*;
public class SolarSystemV3 extends Applet{
int input;
public void init()
{
 String webInput = getParameter("mer");
 if(webInput != null)
 input = Integer.parseInt(webInput);
}
public void paint(Graphics g)
{
 if(input == 1)
 {
 g.drawString("hello mercury", 25, 25);
 }
}
}

here is the HTML:

<body>
<article>
<img src="mercury.jpg" alt="Mercury"/>
<h1>Mercury</h1>
<applet code = "SolarSystemV3.class" width="320" height="120" 
<param = "mer" value = "1"/>
</applet>
</article>
</body>
</html>
asked Apr 15, 2014 at 19:31
1
  • @Braj An int can't be null. Commented Apr 15, 2014 at 19:44

2 Answers 2

2

..here is the HTML:

No it's not. I don't mean it is not there, I mean what's there is not HTML. It is some rubbish hacked out by a programmer that is pretending to be HTML. There are at least 3 errors in it.

To find out what the errors are, use an HTML validation service.

answered Apr 16, 2014 at 7:56
Sign up to request clarification or add additional context in comments.

2 Comments

Yes I haven't noticed it. I just noticed applet tag. Its not a HTML.
@Braj That's why I recommend to programmers to check their 'HTML' with a validation service. Programmers would have to be the worst authors of HTML on the planet. Amateurs generally use an editing app. for HTML and those apps. do a better job, but programmers think to themselves "HTML is just mark-up, I can write it off the top of my head". Unfortunately, they are wrong about that.
1

The problem is here in your HTML. name attribute of param tag is missing.

<param = "mer" value = "1"/>

use

<param name = "mer" value = "1"/>

The parameter mer is not properly defined in HTML.

For more info have a look at Defining and Using Applet Parameters

answered Apr 15, 2014 at 19:48

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.