Teach you how to configure the Applet environment
Java applets, also known as Java Applets, can run in a web browser. Java Applets must be embedded in HTML pages in the form of
I always thought that if I installed the JDK locally and specified the JAVA_HOME and PATH environment variables, all Java programs would be able to run. Later, a colleague asked me to When I helped him solve the problem that a Gantt chart of a project management software could not be run in the web browser, I discovered that the running environment configurations of Java Applet and general Java applications were different. To run Java applications on Windows, as long as you have the JDK binary directory and specify JAVA_HOME and PATH, you can use it directly. You do not need to install it through the JDK installation program. Therefore, you can back up the installed JDK directory as a compressed package. When you reinstall the system or install the Java environment on other machines in the future, you can directly copy the JDK binary compressed package and use it directly after decompression.
But in Windows, when configuring the running environment of Java Applet, it is not enough to only specify the JDK directory. You must meet the following requirements:
1. Use the JRE installation package. Installation
2. The JRE version provides Java Plugin
3 The bit length of .JRE and the web browser must be consistent, such as both 32-bit or 64-bit software versionsThis is because the JRE will install Java-related Information is written to the registry and a Java Plugin is installed for the web browser. When the Java Plugin of the web browser runs an Applet, it will first read the Java information from the Windows registry and then execute the Applet program.
It should be noted here that different versions of JRE support different web browsers and versions. My local web browsers include IE8, Firefox16, and Chrome19. After installing JRE6u11, only IE8 can run Applets; under Firefox16, you can see that the Java Plugin is installed through about:plugins, but cannot run Applets; while under Chrome19, it shows that there is no Java Plugin installed. Java Plugin. After installing JRE7u9, all browsers can run Applets. So, the simplest thing is to just install the latest JRE version. Usually if the browser does not have Java Plugin installed, the user will be prompted to install the plug-in when running a web page with an Applet. Generally, it can be installed directly.
Java Tester is a website that is used to check the locally installed JRE version and software manufacturer. It can also check whether the web browser can run the Applet program:
Java Tester - What Version of Java Are You Using?
For ordinary users, it is very simple to install the Applet running environment, but sometimes it is the browser of Java developers that cannot run Applet, which is a bit shabby. Java developers often install multiple Java versions on their computers. Sometimes they directly move or
deletethe JDK directory without uninstalling it through the Windows control panel, resulting in residual Java installation information in the Windows registry. , there is no problem running the Java application, but the Java Plugin cannot find the JRE in the web browser to execute the Applet. After installing JRE, a Java icon will appear on the Java control panel. If you find that the Java icon cannot be displayed, it will prompt that the program cannot be found when you click it, as shown below:
The Java icon that cannot be displayed above means that the JRE environment on Windows cannot be found and the JRE needs to be reinstalled. The normally available JRE environment is as shown below:
Click the Java icon to open the Java Control Panel (javacpl), indicating that the JRE on Windows is already available.
To sum up, Java applications and Java Applets have different requirements for the running environment. When a Java application is running, there is no need to find the registry, as long as the JDK directory is specified, it can be run. For Applet applets, the Java Plugin in the web browser needs to find the JRE environment through the registry and run the Java Applet.
Therefore, it is recommended that the local Java environment:
Install a higher version of JRE to support newer web browsers running Applets Program The JDK required for Java applications,
directly copy the JDK binary directory and use , no installation is required, multiple JDKs can coexist, and the JDK version must be used when executing.
Appendix 1: If you cannot reinstall JRE, you can follow the steps in the following article to clear the remaining Java installation information in the registry and then run the JRE installer:
Appendix 2: How to enable Java in a web browser? (It must meet the prerequisite that JRE is installed and available, and the web browser has Java Plugin installed) www.java.com/zh_CN/download/help/enable_browser.xml Appendix 3: Hello Applet 1. Write an Applet applet, Inherit Applet base class: Java code 2. Compile Applet Java code 3. Embed the Applet applet in the index.html web page Html code Note: *Applet must be embedded into a web page to run. Use the tag to embed Applet *codeAttributeSpecify Applet Class *The archive attribute specifies the jar package where the applet is located. If it is not packaged, it can be omitted *The codebase attribute specifies the root directory used to find the Applet class and Jar package. This directory is relative to For the directory where the web page is located, specify a relative directory. codebase="." means to search for the Applet applet in the web page directory. *The tag should be used in the web page. When using , it can run normally in the web page, but the applet window cannot be displayed in the appletviewer. 4. Use appletviewer to test Applet applet Java code 5. Run Applet in web browser Applet Drag the web page to the browser to view it, or deploy the web page and Applet applet to the HTML document directory of Apache to access it through the URL. 【Related Recommendations】 1. Special Recommendation: "php Programmer Toolbox" V0.1 version download 3.Detailed explanation of the difference between Application and Appletpublic class HelloApplet extends Applet {
private static final long serialVersionUID = 5511892956119084309L;
@Override
public void init() {
Graphics g = this.getGraphics();
paint(g);
}
public void paint(Graphics g) {
g.drawString("Hello Applet!", 45, 45);
}
}
CMD>javac HelloApplet.java
...
<applet alt="" code="cn.david.applet.HelloApplet.class" archive="applet-1.0.0-SNAPSHOT.jar" width="200" height="200"
codebase=".">
</applet>
...
CMD>appletviewer index.html
The above is the detailed content of Teach you how to configure the Applet environment. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Guide to Smith Number in Java. Here we discuss the Definition, How to check smith number in Java? example with code implementation.

In this article, we have kept the most asked Java Spring Interview Questions with their detailed answers. So that you can crack the interview.

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

Guide to TimeStamp to Date in Java. Here we also discuss the introduction and how to convert timestamp to date in java along with examples.

Capsules are three-dimensional geometric figures, composed of a cylinder and a hemisphere at both ends. The volume of the capsule can be calculated by adding the volume of the cylinder and the volume of the hemisphere at both ends. This tutorial will discuss how to calculate the volume of a given capsule in Java using different methods. Capsule volume formula The formula for capsule volume is as follows: Capsule volume = Cylindrical volume Volume Two hemisphere volume in, r: The radius of the hemisphere. h: The height of the cylinder (excluding the hemisphere). Example 1 enter Radius = 5 units Height = 10 units Output Volume = 1570.8 cubic units explain Calculate volume using formula: Volume = π × r2 × h (4

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

Java is a popular programming language that can be learned by both beginners and experienced developers. This tutorial starts with basic concepts and progresses through advanced topics. After installing the Java Development Kit, you can practice programming by creating a simple "Hello, World!" program. After you understand the code, use the command prompt to compile and run the program, and "Hello, World!" will be output on the console. Learning Java starts your programming journey, and as your mastery deepens, you can create more complex applications.
