Continue learning!
Create a helloworld_app.java file in the D: \ majava \ folder and write the following content:
Import Java. AWT .*;
Import Java. Applet .*;
Public Class Helloworld_app
Extends Applet
{
Public Void Init (){
}
Public Void Paint (Graphics g)
{
G. drawstring ("Hello world! ", 25, 25 );
}
}
Then I wrote a helloworld_app.html file and wrote the following:Code:
< Applet Code = "Helloworld_app" Width = 150 Height = 100 >
</Applet>
Compilation SourceProgram: D: \ myjava> javac helloworld_app.java
Run: D: \ myjava> appletviewer helloworld_app.html
This problem occurs during execution:
"Warning: the attribute file of appletviewer cannot be read". There is another directory. Forget it. Then Baidu gave it a try and the solution was as follows:
1. Open the Command Prompt window (CMD)
2. Enter policytool and press Enter.
3. In the policytool dialog box, click Add Policy entry (add rule project)
4. Click Add permission (add permission)
5. Click the license drop-down menu and select all permission.
6. Click OK)
7. Click Done)
8. select Save As from the File menu (save as from the File menu)
9. In c: \ Documents ents and Settings \ Administrator (current operating system username) \ "file name" (it seems that it can be in any directory, and I saved it to the C root directory)
After performing the nine steps, compile and run the program again, and there will be no above errors!
Cut a picture to commemorate it.
In addition, double-click the webpage file to execute it in the browser!