Http://www.cnblogs.com/jdksummer/articles/2655711.html
Reference page: http://docs.oracle.com/javase/tutorial/deployment/deploymentInDepth/embeddingJNLPFileInWebPage.html
Note: If the previously configured Java environment in your system is jdk1.6, uninstall it and change it to jdk7. To run WorldWind on a webpage, it must be configured with JDK 7.
1. fully understand how to configure the WorldWind development environment in eclipse to ensure that the sample program runs properly. Refer to my blog: http://www.cnblogs.com/jdksummer/articles/2644389.html
2. Create a web project named myworldwind and configure the WorldWind Library (see step 1 ).
Create an Applet Class in the project. The content is as follows (this is an example of WorldWind source code ). Copy the config folder from the downloaded WorldWind installation package to your src directory (the config folder is the read configuration of the WorldWind application ).
Set the fixed location of the file), and run as an applet to ensure normal operation.
Wwjappletminimal. Java
package com.summer.applet;import gov.nasa.worldwind.*;import gov.nasa.worldwind.avlist.AVKey;import gov.nasa.worldwind.awt.WorldWindowGLCanvas;import gov.nasa.worldwind.util.StatusBar;import javax.swing.*;import java.awt.*;public class WWJAppletMinimal extends JApplet{ public WWJAppletMinimal() { } public void init() { try { // Create World Window canvas. WorldWindowGLCanvas wwd = new WorldWindowGLCanvas(); this.getContentPane().add(wwd, BorderLayout.CENTER); // Create the default model as defined in the current worldwind configuration file. wwd.setModel((Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME)); // Add the status bar, and forward events to the status bar to provide the cursor position info. StatusBar statusBar = new StatusBar(); statusBar.setEventSource(wwd); this.getContentPane().add(statusBar, BorderLayout.SOUTH); } catch (Throwable e) { e.printStackTrace(); } } public void stop() { // Shut down World Wind when the browser stops this Applet. WorldWind.shutDown(); }}
Project Structure:
3. Modify myworldwind project webroot/WEB-INF/Web. XML,
Insert a child element into the web-app element with the following content:
<mime-mapping> <extension>jnlp</extension> <mime-type>application/x-java-jnlp-file</mime-type> </mime-mapping>
4. Package the Applet Class into a jar package.
Select a project, right-click --> export --> JAVA --> runnable JAR file, click Next To Go To The export page, enter the following format, and click Finish.
Launch Configuraton: select the project to export
Export destination: select the location of the jar package to export
Libary handling: After my tests, it is best to select "copy required libraries into a sub-Folder next to the generated jar ". This option will package the. Class file of the compiled Applet Class and the config directory in
In a jar package (this is very important, make sure that the packaged applet can find config), that is, the worldstreet above. jar, and put the other dependent packages added in the project in a separate folder. As shown in:
Go to the directory where the jar package is located, double-click to run jar or run Java-jar worldstreet. jar on the command line to confirm that the package is successful.
5. Compile the JNLP file to ensure that the JNLP file can run. Write the webpage to ensure the format is correct and the content is correct. See: http://www.cnblogs.com/jdksummer/articles/2661853.html for details
Attachment: worldstreet. JNLP, worldstreet. jsp
Click here to download.
5. Place worldstreet. jar and the worldstreetmap_lib, worldstreet. JNLP, and worldstreet. jsp folders in the wwj folder, and copy wwj to the webroot directory of the myworldwind Project (that is
Tomcat server root directory ). Assume that my host name is summer2, the deployed server is http: // summer2: 8080/myworldwind/, and wwj is directly located in the root directory of the server.
Http: // summer2: 8080/myworldwind/wwj/worldstreet. jsp to access the complete applet.
OK. The WorldWind of the applet version is ready!
Bytes -------------------------------------------------------------------------------------------------------------------------
Client notice:
After the server is configured, if a computer wants to access WorldWind on the webpage, it also needs to install java7 on the Local Computer and put the WorldWind library file under the Local java. libary. Path directory. Summary:
1. Download and install jdk7.
2. Determine the directory pointed to by Java. libary. path on the local machine. I personally tested that/usr/lib is available in Linux and C:/Windows is available in windows. For Linux, put the libgluegen-rt.so in the WorldWind package, libjogl. So,
Libjogl_awt.so, libjogl_cg.so four files are copied to the selected java. libary. Path directory; if it is a Windows system, copy gluegen-rt.dll, jogl. dll, jogl_awt.dll, jogl_cg.dll four files to the selected
Java. libary. Path directory.