Question

I am a Java beginner, using Eclipse. I am trying to understand the NASA World Wind package. Specifically code that looks like this:

    protected WorldWindow wwd;
    protected StatusBar statusBar;
    protected ToolTipController toolTipController;
    protected HighlightController highlightController;

When I mouse over "WorldWindow" it says

Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

The code compiles and runs, though.

However, it points to a package in a JAR file. I can find the class it is referring to. But I cannot read the class file. When I double click on it, I get "Source not found" in the Class File Editor.

I want to understand how this code works. How can I read the class files within the JAR?

Was it helpful?

Solution 3

The project you are using is open source, so you have a few options at this point.

  1. Ideally you can associate the source code and javadoc with the .jar file in Eclipse. This will allow you to directly view (read only) the source and documentation for the library from within Eclipse. To do this, you will need to:
    • download the source code and/or the javadoc. These items may very well be included in the archive you used to originally download the project (either as a jar, zip, or expanded subdirectory).
    • inform Eclipse about the relationship between your compiled jar file and the source/javadoc. See this guide
  2. ☆ instant gratification ☆ View the source code directly from the project repository. The World Wind project appears to be accessible at http://worldwind31.arc.nasa.gov/svn/trunk/WorldWind/src/
  3. You can decompile the compiled code. This solution is more useful if you're trying to investigate a closed source project or if you're debugging something unusual.

OTHER TIPS

Reading the actual class files in the jar would require decompiling with a tool such as JD-GUI.

However a quick Google search returned the Javadocs for the entire library.

http://builds.worldwind.arc.nasa.gov/worldwind-releases/daily/docs/api/index.html

Enjoy!

Use a decompiler - try JD-Eclipse, an Eclipse plugin. After installing it, you should be able to click on the classes you want to view and be directed to decompiled code from within the JAR file.

enter image description here

You have to "decompile" the class file into readable java code. There are several good decompilers out there, here is a very popular one JD-GUI.

Also if you are using an IDE you often can download the src files and attach them just to use as javadocs while writing your program.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top