Presentation is loading. Please wait.

Presentation is loading. Please wait.

Putting Applets into Web Pages.  Two things are involved in the process of putting applets onto web pages ◦ The.class files of the applet ◦ The html.

Similar presentations


Presentation on theme: "Putting Applets into Web Pages.  Two things are involved in the process of putting applets onto web pages ◦ The.class files of the applet ◦ The html."— Presentation transcript:

1 Putting Applets into Web Pages

2  Two things are involved in the process of putting applets onto web pages ◦ The.class files of the applet ◦ The html file of the page  Remember: any Java source file that compiles correctly will produce a.class file.

3  Compiled.class files for Java source code should be found: ◦ C:/UserName/workspace/NameOfProject/bin  It may also be found in ◦ C:/UserName/Android/workspace/NameOfProject/ bin

4  The HTML file should be created inside the same folder as the.class files for the applet. ◦ This is to reduce complexity in defining the path to the applet class in the HTML file.  You could start creating an HTML file in Notepad by: ◦ Starting a new text file, and adding your code from there ◦ When it comes time to save, remove the *.txt extension, and add ‘.html’ to the end of the file instead. (Ex: MyHtmlPage.html)

5

6  HTML is a markup language, using a system of tags to define elements of a document.  is a tag that denotes a start of an html file, while denotes the end.  Likewise, and are used in the same way.

7  You’ll notice inside the first applet tag, there are attributes assigned inside it (code, width, height) ◦ ‘code’ is the directory where the HTML file would be able to find the main.class entry point for the applet. ◦ ‘width’ and ‘height’ define the size as it appears on the web page. ◦ Note that the values assigned to these attributes are defined in double quotes.

8  If you have to change a line in the source code of the Java files and recompile, you should replace the.class file in the html directory with the new one.  When running Java applets, the user must have the Java Runtime Environment installed.  For security or other reasons, some systems may not run Java content through web pages.

9  With the newest version of Java, unsigned applets are not allowed to run on any machine.  This means that if we try running our applet through an html page we created, the applet will not run at all, because it is considered a security risk.  Therefore, we’ll need to create an exception for this.

10  Open the Java Control Panel ◦ On Windows start, search for “Configure Java” ◦ Java\jre7\bin\javacpl.exe  Go to the Security tab, and click the “Edit Site List…” button.  In the blank space on the dialog, type in the file or html location of the html file you want to run. ◦ Ex: http://math.uaa.alaska.edu/~android/ java/unit5/unit5applet  Click Add, then OK on both dialogs. You should be able to run that applet now.


Download ppt "Putting Applets into Web Pages.  Two things are involved in the process of putting applets onto web pages ◦ The.class files of the applet ◦ The html."

Similar presentations


Ads by Google