Hello World Wind – Basic World Wind Java SDK Tutorial
I am just getting started on an application that uses the World Wind Java SDK. As I learn more about it I will post tips and lessons, more for myself as a reminder of how I did something, but maybe someone else will find use of them. This lesson will be a very simple Hello World. I will explain how to get the WWJ SDK going in NetBeans in this article.
Note: I will update this article for Eclipse as well, as soon as VEP becomes available for the Europa release – why don’t they have a Visual Editor built into the core? OK, I will save that for another blog subject, moving on…
The first thing we need to do of course is download and unzip the WWJ SDK – http://worldwind.arc.nasa.gov/java/
After you have that downloaded and unzipped the SDK we can set up our IDE.
For Netbeans 5.5.1:
- Open Netbeans.
- 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. - 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.
- 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 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 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.
- 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; - 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\worldwind
- 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.

- Success!

Hi,
My name is James Branam and I’m the NetBeans Community Docs Manager. Your blog entry would make a fantastic tutorial for our Community Docs wiki (http://wiki.netbeans.org/wiki/view/CommunityDocs). Would you be willing to contribute it? If you need any help or have any questions, please contact me at james[dot]branam[at]sun.com. I look forward to hearing from you.
September 4, 2007 at 8:34 am
HI.
I Tried your tutorial but for some reason I don’t get the image of the globe, only place names.
My full install of worldwind 1.4 works OK, so the problem is not the graphics card.
Any ideas?
Great work
September 24, 2007 at 6:03 pm
That is rather strange, I think you are right about the video card drivers, usually you don’t see anything if that is the problem. One thing you may check is the minimum Java requirements, I know it requires a fairly recent Javaa SDK/Java runtime. Also, what version of the WWJ SDK are you using? I think they just came out with a new release of the WWJ SDK.
Here’s what you can do, you can run the example which is called BasicDemo.jar, that comes with the WWJ source. If that doen’t run either, then try getting the latest version of Java. If the demo runs fine then, it’s a problem with your code (or my code). Comment back if you still can’t get it running. I would be glad to help.
September 24, 2007 at 6:15 pm
HI,
I followed you tutorial but i am getting an error
at the following lines when I initialize
Model m (Model)
WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
worldWindowGLCanvas1.setModel(m);
netbeans says that it can not find the variable ABKey
I curious as to how is how is this going to turn out.
thanks
September 25, 2007 at 7:49 pm
I think the error may be a typo, should be AVKey. If you do indeed have ABKey you will get the following error:
symbol : variable ABKey
location: class WorldWindMain
Model m = (Model) WorldWind.createConfigurationComponent(ABKey.MODEL_CLASS_NAME);
1 error
BUILD FAILED (total time: 0 seconds)
I hope this helps. Good luck!
September 25, 2007 at 8:30 pm
I’m beginner of Java, when i see this example then i try.
I newly installed the java and netbeans.
I follow the directions of the example, then this is come with the netbeans error.
netbeans says that it can not find the variable AVKey
Im curious what this error means?
The same as lawrence khan say:
# lawrence khan Says:
September 25th, 2007 at 7:49 pm
HI,
I followed you tutorial but i am getting an error
at the following lines when I initialize
Model m (Model)
WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
worldWindowGLCanvas1.setModel(m);
netbeans says that it can not find the variable ABKey
I curious as to how is how is this going to turn out.
thanks
September 26, 2007 at 2:07 am
this is the compilation error:
symbol : variable AVKey
location: class HelloWorldWindMain
Model m = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
1 error
September 26, 2007 at 2:13 am
I have the same response as Laurence. Definately have AVKey in the expression (used the copy/paste on the expression), and the error says:
C:\Documents and Settings\Java Aps\Hello Worldwind\src\HelloWorldWindMain.java:16:
cannot find symbol
symbol : variable AVKey
location: class HelloWorldWindMain
Model m = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
1 error
BUILD FAILED (total time: 1 second)
September 26, 2007 at 2:13 am
Alright, give me a little while to try and recreate the error. I have gone through the tutorial step by step and it compiles and runs for me. Like I said, I think I read there is a new release, maybe you guys are using a different version of WWJ SDK. Let me try that and see what I come up with, if it differs I will update the tutorial. I am at work now so it may be later today before I am able to test.
September 26, 2007 at 9:06 am
Alright guys it is with the new version. Simply add this import:
import gov.nasa.worldwind.avlist.AVKey;
September 26, 2007 at 10:36 am
Getting closer
Here is the error I get now ..
java.lang.NoClassDefFoundError: Wind\worldwind
Exception in thread “main”
Java Result: 1
The build was successfull, but nothing hapens.
Van!!
September 26, 2007 at 5:15 pm
I suspect the problem may be that it can’t find the library files. Java has trouble locating libraries if the directory path has space in it, such as “C:\Documents and Settings\User\Desktop”. I suspect that only because it has just “Wind\worldwind” like it was cut off. You may try moving the World Wind SDK to C:\worldwind, and also updating the library locations (steps 2,4,8). If you don’t have spaces in your path and you already know all this, just tell me to shut the hell up
I am lousy at trying to debug others code so bare with me
Let me know if this is not it. Also, feel free to email me glantz-at-gmail-dot-com if you have questions.
September 27, 2007 at 8:59 am
I have a problem when resizing the JFrame. Making the window larger works as expected but making the JFrame smaller does NOT rezize the contents of WorldWindowGLCanvas so I end with only seeing the top left corner of the world.
This problem does NOT exit with BasicDemo.
I am using release 20070920.
Any suggestions?
I assume this is an Swing/AWT issue.
September 28, 2007 at 4:36 am
Good Job!.
Please help me…
follow all the instructions of the tutorial, but gives the following error me when trying to run
init:
deps-jar:
compile:
run:
java.lang.NoClassDefFoundError: and
Exception in thread “main”
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
thanks. errod1.
September 28, 2007 at 9:59 am
I put World Wind SDK to C:\worldwind.realese.20070817 and also change de library locations (step 2,4,8)
However i get error exception:
Exception in thread “AWT-EventQueue-0″ java.lang.UnsatisfiedLinkError: no jogl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
what i can do?
tanks
September 29, 2007 at 1:28 pm
thanks!
September 29, 2007 at 8:35 pm
Ernesto, it looks like it cannot find the worldwind.jar make sure there are no spaces in your unzipped worldwind directory path and also make sure your imports are there.
Rodalpho_BR, looks like your almost there, just can’t find the jogl.jar. Make you you add it in your runtime libraries.
Also, I used the 20070817 release of the WWJ SDK. To follow along I would recommend that version. I will try and keep up with the versions they release and update this as needed.
Peter, I will have to check into that further, that is a good question. Did not know there was a minimum size. I will play around a bit and see if I can come up with anything.
October 1, 2007 at 8:49 am
Thank you for sharing!
October 6, 2007 at 1:29 am
When I compile the code, the window comes up, however, it is not a globe. I see a lot of dots and a small minmap of the globe. Also, whenever I move my mouse the entire screen has to redraw its self.
Any thoughts..?
Thanks!
October 10, 2007 at 5:52 pm
this is the error i get:
init:
deps-jar:
Compiling 1 source file to /home/kevin/HelloWorldWind/build/classes
/home/kevin/HelloWorldWind/src/HelloWorldWindMain.java:20: cannot find symbol
symbol : variable worldWindowGLCanvas1
location: class HelloWorldWindMain
worldWindowGLCanvas1.setModel(m);
1 error
BUILD FAILED (total time: 0 seconds)
January 1, 2008 at 8:49 pm
Peter, I fixed the resizing problem by right clicking on my jframe in the inspector window, selecting Set Layout, and choosing BorderLayout. I previously had Free Design selected and resizing didn’t work well.
February 13, 2008 at 9:40 pm
Hi. I’m new to World Wind Java…new to Java too. I have 2 questions.
1) I followed this tutorial and got the window after “Run”, but the globe never showed up. I got the stars, atmosphere, compass, etc., but no globe. Any ideas?
2) Does anyone know of a good beginner’s tutorial for adding placemarks from an XML file? I have some info from the World Wind Java forum, but I haven’t been successful yet.
Thanks!
February 20, 2008 at 2:32 pm
Hi again. Nevermind about my 1st question. I was working off of a server, which I’m guessing doesn’t have the right graphics card.
I still would like to know how to add points to the BasicDemo using an xml file. I just need guidance to get started. I’m ok with creating the xml file. I just don’t know what files go where and if I need any type of add on.
February 20, 2008 at 3:13 pm
Thanks for sharing this. Good info.
March 7, 2008 at 2:05 pm
I am using netbeans 6.1 and I can’t follow the rest of the tutorial beyond the canvas because the source doesn’t provide me with the same window you are using. Do you have a tutorial for 6.1?
August 31, 2008 at 5:18 pm
I tried to run the program you wrote. I get an error like that:
init:
deps-jar:
Created dir: C:\Documents and Settings\Gökçen\Belgelerim\NetBeansProjects\JavaApplication3\build\classes
Compiling 1 source file to C:\Documents and Settings\Gökçen\Belgelerim\NetBeansProjects\JavaApplication3\build\classes
compile:
run:
java.lang.NoClassDefFoundError: and
Caused by: java.lang.ClassNotFoundException: and
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: and. Program will exit.
Exception in thread “main”
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Also i didn’t understand the VM options part. is the folder you give unzipped one or another one?
thanks…
November 26, 2008 at 1:45 pm
Hello,
I just started to use worldwind java..I am able to successfully run within NetBeans. I built my application as an applet, and it is launched within an html from a Web app hosted on Tomcat. The applet has trouble finding the libraries. I tried moving them to Tomcat shared library folder, into the Web app directory itself..all with no success..
Any suggestions?
Thanks, Suma.
December 1, 2008 at 12:26 pm
I have tried this with Netbeans 6.5 to no avail. I does not recognize the worldWindowGLCanvas1 as a Component? I added it as a Swing AWT Bean? So the HelloWorldWindMain frame code has a ‘symbol not fould’ in ‘getContentPane().add’ line. Any help would be great. I do not want to reinstall Netbeans to get 5.5 if possible.
Mark
private void initComponents() {
worldWindowGLCanvas1 = new gov.nasa.worldwind.awt.WorldWindowGLCanvas();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().add(worldWindowGLCanvas1, java.awt.BorderLayout.CENTER);
pack();
}//
February 18, 2009 at 12:32 pm
Anyone who gets this error:
java.lang.NoClassDefFoundError: Wind\worldwind
Exception in thread “main”
Java Result: 1
Try Step 8 again, but this time make sure to put quotes around your folder path. So it should be like this:
-Djava.library.path=”C:\Users\george\Desktop\worldwind”
Hope this helps!
June 19, 2009 at 8:40 am
Hi,
I keep on repeting this tutorial.
It is the only one that shows how to do it from the scrach.
But I always end up having the same error “can not find symbol” in this line:
.addComponent(worldWindowGLCanvas1,javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
Does anybody know why?
Best,
Carlos
October 5, 2009 at 7:19 pm