Why this Java Applet do not run in Applet viewer as .class file but runs if embedded in HTML ?
-
I am enclosing the following code, which if compiled do not seem to be running as .class file from the command prompt with the Applet viewer. But on the contrary, if the applet is embedded in a HTML file, it runs smoothly with the applet viewer. Why doesn't it run as a .class file from the command prompt ? Any help would be highly appreciated, thanks in advance import java.awt.*; import java.applet.*; public class Appl3 extends Applet { Label l1,l2; TextField t1; TextArea t2; Button b1,b2; public void init() { l1 = new Label("Enter Name :", Label.CENTER); l2 = new Label("Enter Message :", Label.CENTER); t1 = new TextField(10); t2 = new TextArea(" ",5,10); b1 = new Button("Submit"); b2 = new Button("Cancel"); add(l1); add(t1); add(l2); add(t2); add(b1); add(b2); repaint (); } public void start() { repaint (); } public void stop() { repaint (); } public void destroy() { repaint (); } }
-
Answer:
appletviewer is supposed to run an html file. To do this little program the 'official' 'correct' way we would have the separate .htm file and run it with the command >$ appletviewer Appl3.htm if, on the other hand you put this in the top of the source file (Appl3.java) /** <applet code=Appl3 width=300 height=300></applet> */ the command line looks like this >$ appletviewer Appl3.java the commented, hidden html is since Java2 vers. 1.2
Kushal C at Yahoo! Answers Visit the source
Related Q & A:
- why a reduced ring can be embedded into a sum of integral rings?Best solution by Mathematics
- how to close the applet in java code?Best solution by Stack Overflow
- How to create a java applet?Best solution by Stack Overflow
- How to convert a HTML file to XML file?Best solution by Stack Overflow
- Why doesn't a Nissan truck run smooth in overdrive?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.