WWJava in NetBeans IDE
From World Wind Wiki
[edit] Compiling and running the SDK examples
This step by step guide was created with NetBeans 6.x and the 0.5.0 release of the SDK. However, the general principals outlined here should work regardless of the SDK version.
- Unzip the SDK
- Open NetBeans and create a New Project using the "Java Application" template. Fill in the required details but uncheck the 'Create Main class' box. Your new project should reside in a clean directory.
- Rename WorldWind's 'build.xml' to something else (ww_build.xml) and copy all the WorldWind's unzipped content to your NetBeans project folder so that the src folders overlap. You should end up with a folder structure very similar to the WorldWind unzipped folder, plus a 'nbproject' and a 'test' folders. The 'build.xml' file is the one created by NetBeans, not the one that came with the zip (which is why we renamed it earlier).
- From NetBeans, you will notice that some folders/classes are marked with a red exclamation mark. We now need to tell the project about the required libraries. Right-click your project's node and select 'Properties' (typically the last menu item). Select the 'Libraries' node from the Categories tree and press the 'Add JAR/folder' button on the right. Keeping CTRL down, select the 'gluegen-rt.jar' and 'jogl.jar' that are now inside your project folder. Click 'ok'.
- At this point, only 2 classes in the '...examples.Applet' package don't compile (still have the red exclamation mark). Go back to the 'Libraries' category like before, but this time you need to add the 'plugin.jar' located in your JDK/jre/lib directory (for example, C:\Program Files\Java\jdk1.6.0_10\jre\lib\plugin.jar)
You can now run any of the examples by right-clicking them and selecting 'Run File' from the contextual menu.
[edit] Original entry from Geertjan's log when the 0.1 SDK was initially released
Now that the worldwind.jar for NASA World Wind is available, here's the absolutely simplest scenario that you can implement very quickly and efficiently with NetBeans IDE:
- Download and unzip the World Wind Java SDK.
- In NetBeans IDE, select Tools / Palette Manager from the main menu. In the Swing/AWT Components Palette Manager, browse to the worldwind.jar. Select WorldWindowGLCanvas component and add it to the Beans category.
- Create a new Java application in NetBeans IDE. Open the Project Properties dialog box. In the Libraries tab, put the worldwind.jar on the compile time classpath. Put jogl.jar and gluegen-rt.jar, which are both in the World Wind Java SDK you downloaded, on the runtime classpath.
- Again within the Project Properties dialog box, use the Run tab to add a line such as the following in the VM Options text field:
-Djava.library.path=/path/to/unzipped/nasa/download
- Create a JFrame in your application. Drag and drop the WorldWindowGLCanvas from the palette onto the JFrame and, if you like, resize to cover the whole JFrame, with this result:
- Create a helper class, with this very basic content:
public class WWHelper {
private WWHelper() {
}
public static void setup(final WorldWindow ww) {
Model m = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
ww.setModel(m);
}
}
- Then, back in the JFrame, add this line after the initComponents(), in the constructor:
WWHelper.setup(worldWindowGLCanvas1);
- Run the application. Let the JFrame's constructor be the application's starting point. Here's what you should see:
- Use the mouse, or your keyboard's alternative, for panning and zooming:
This is the start of a series of blog entries on this topic. And a NetBeans tutorial will follow, as well as related NetBeans modules, such as templates and so on. With thanks to Ken Russell for help and support.
Source: Geertjan's Weblog




