Use archive in applications and in applets applet

Source: Internet
Author: User
Tags root directory

You have to thank Java 1.2 for the jar enhancements provided. You can now run the applets and apps that have been archived (archived). For example, if you send a-jar command to the Java interpreter, you can run an already archived (archived) application. Java applications packaged in a jar file can be executed directly on Windows or the Solaris desktop.

The way these archive files (archives) are executed automatically depends on the system you are using. When you install the Java 1.2 Runtime environment in a 32-bit Windows system, Setup registers a default jar file connection. After that, you can invoke the Java interpreter through the-jar option, and you can run the jar file automatically. For the Solaris 2.6 operating system, sun actually extends the kernel of the operating system so that the system can recognize the jar file. The extension of the kernel allows Solaris 2.6 to invoke the Java interpreter directly through the-jar option, so that the Solaris system can execute the archive file as it would an intrinsic Solaris executable file.

Running an archived (archived) Java applet differs from running an archived (archived) application because you need to tell Java applet Viewer or Java-enabled browsers how to use applets. Typically, you can do this by creating a Web page that contains a <APPLET> logo. The attribute value of the identity tells you what the browser is about the applet, such as its class name and location.

Using the <APPLET> logo, you can associate one or more archives with the APPLET. When you use archive files in a small program, browsers always look for the required classes and resource files in archives. If the browser cannot find these files in the archives, the browser attempts to obtain them from the server. This is true if the archives does not exist.

The attribute used to mark the Java Archive in the applet is archive. Property archive are always used in conjunction with the Code property. The code attribute indicates the name of the main applet class, and the archive property identifies the location of the archive file, which can be defined by a relative or absolute URL. For a relative URL, your browser determines the location of the archive file based on the root directory of the applet code. If you recall, the root directory where the code resides is the location of the applet's source code, which can be marked with the CODEBASE attribute.

In the following example, the main applet class is Myapp.class, and the browser looks for it in the corresponding property file. If the browser cannot find the applet class, the browser will go to the server and look for the applet class.

<applet code= "Myapp.class" archive= "Myapp.jar" width= "the" "height=" ">

</APPLET>

If an applet uses more than one archive, you can enter the URL of the archives file in the comma-delimited list. In the following example, the applet uses two archives files. The first archive is named Strider1.jar, and the second archive is named Strider2.jar.

<applet code= "Strider.class" archive= "Strider1.jar,strider2.jar" width= "a" height= ">"

</APPLET>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.