Lost_User
asked on
Java Applet wont load on HTML file
Hi,
I am trying to upload my java that i have worked on and it is throwing an excepection.
Jave: Helloworld.java
HTML:
Error:
I am able to compile the java view it in console but when I load the html file it throws the above error.
I am trying to upload my java that i have worked on and it is throwing an excepection.
Jave: Helloworld.java
class Helloworld {
public static void main(String args[]){
System.out.println("Hello World");
}
}
HTML:
<html>
<body>
<h2>My first Java program</h2>
<applet code="Helloworld.class" height="200" width="250">
</applet>
</body>
</html>
Error:
" Application Error
RuntimeException
java.lang.reflect.InvocationTargetException"
I am able to compile the java view it in console but when I load the html file it throws the above error.
Applets are not simple java programs. There is a tutorial you should read
ASKER
I have used that also and it throws the same error...
http://docs.oracle.com/javase/tutorial/deployment/applet/getStarted.html
http://docs.oracle.com/javase/tutorial/deployment/applet/getStarted.html
ASKER
import javax.swing.JApplet;
import javax.swing.SwingUtilities;
import javax.swing.JLabel;
public class Helloworld extends JApplet {
//Called when this applet is loaded into the browser.
public void init() {
//Execute a job on the event-dispatching thread; creating this applet's GUI.
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JLabel lbl = new JLabel("Hello World");
add(lbl);
}
});
} catch (Exception e) {
System.err.println("createGUI didn't complete successfully");
}
}
}
Failed to run due to "Exception in thread "main" java.lang.NoSuchMethodErro
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Open in new window