i am learning java at this moment and i’ve read somewhere that i can also run my java codes in a browser with an applet. if i try to use it, it says error click here for details.
the problem is that the java program does work in command prompt but not in the browser.
here is my HTML code. (Planet.class and the html file are both on my desktop)
<applet code="Planet.class" width=500 height=500 />
this is my java code (this code works nice in command prompt; don’t try to get what it’s exactly doing it just makes a rhombus out of *’s.) :
class HelloWorldApp {
public static void main(String[] args) {
int n=20;
int i;
int k;
int j;
for (i=1;i<=n;i++)
{
for (k=n-i;k>=0;k--)
{ System.out.printf(" ");}
for (j=1;j<=2*i-1;j++)
{System.out.printf("*");}
System.out.printf("\n");
}
for(i=n-1;i>=1;i--)
{
for (k=0;k<(n-i)+1;k++)
{ System.out.printf(" ");}
for(j=2*i-1;j>=1;j--)
{System.out.printf("*");}
System.out.printf("\n");
}
}
}
i believe that it is just because the printf isn’t supported in the browser but maybe i’m doing something else totally wrong please tell me.
AppletorJApplet.Please read http://docs.oracle.com/javase/tutorial/deployment/applet/index.html