HelloWorldWindJavaSDK

Introduction

This lesson will be a very simple Hello World demonstrating the Nasa World Wind Java SDK. I will explain how to get the WWJ SDK going in NetBeans 5.5.1 in this article. Before we get started you need to make sure that you download and unzip the World Wind SDK - Java World Wind SDK.

Steps

1. Open Netbeans.

2. Add the WorldWindowGLCanvas to the palette.

Choose Tools->Palette Manager->Swing/AWT Components. Click the Add from JAR button. Browse to the unzipped worldwind sdk directory and choose worldwind.jar, click Next. This will list all the JavaBeans inside the JAR, choose the WorldWindowGLCanvas, click Next. Choose Swing as the Palette Category, click Finish. Click Close on the Palette Manager.

3. Create a new Java Project.

Choose File -> New Project. Choose General - Java Application and Click next. Choose a project name, for the example I chose “HelloWorldWind”, uncheck the “Create Main Class” check box, click Finish.Create new Java Project File:Create the Java Project

4. Add the libraries to your project.

Right click on your newly created project from the project explorer frame and choose Properties. Choose libraries from the categories list. With the Compile tab selected, click Add JAR/Folder button. Browse to your unzipped worldwind directory and choose worldwind.jar. Now select the Run tab and add jogl.jar and gluegen-rt.jar. Click OK to close the Project Properties.Add the Libraries File:Add the Libraries

5. Add a JFrame Form to your project.

Right click you project and choose New->JFrame Form. Enter a class name, I chose “HelloWorldWindMain”, click finish.Add JFrame File:Add a JFrame

6. Add the WorldWindowGLCanvas to your JFrame.

Simply drag and drop the WorldWindowGLCanvas from the palette onto the JFrame. Here you can resize the WorldWindowGLCanvas, so that it takes up the full JFrame.Add WorldWindGLCanvas File:Add WorldWindowGLCanvas

7. Initialize the WorldwindowGLCanvas class.

Click on the source tab. Add import gov.nasa.worldwind.*; to the source just below the first set of comments. Inside your HelloWorldWindMain() method, just after initComponents(); add the following:

Model m = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
worldWindowGLCanvas1.setModel(m);

Update:If you are using release 20070817 0 - you will also need to import:

import gov.nasa.worldwind.avlist.AVKey;

8. Add the VM command line options.

The last step is telling our project where to find everything. Right click you project and choose Properties. With the Run category selected enter -Djava.library.path=/path/to/directory in the VM Options text box, click OK. Example: -Djava.library.path=C:\Users\george\Desktop\worldwindAdd VM command line options File:VM command options

9. Run the Project.

Choose Run->Run Main Project, or, hit F6. The first time you run it will ask you to select the main class, choose the HelloWorldWindMain, click OK.Run the project

10. Success!

File:World Wind Example For this and more examples and tutorials, visit my blog - www.georgelantz.com.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo