简体   繁体   English

美国宇航局Worldwind:你如何解决这些奇怪的运行时异常?

[英]Nasa Worldwind: How do you fix these weird run time exceptions?

Nasa Worldwind SDK has some examples that I wish to run. Nasa Worldwind SDK有一些我希望运行的例子。 There are two ways I am trying to run the examples provided in the SDK: 我尝试运行SDK中提供的示例有两种方法:

  1. Create an Eclipse project using the entire SDK source folder. 使用整个SDK源文件夹创建Eclipse项目。
    • point to all the worldwind dependencies (*.jar and *.dll files) 指向所有worldwind依赖项(* .jar和* .dll文件)
    • Go to the folder with examples: src\\gov\\nasa\\worldwind\\examples. 转到包含示例的文件夹:src \\ gov \\ nasa \\ worldwind \\ examples。
    • Run the example ApplicationTemplate.java main. 运行示例ApplicationTemplate.java main。
  2. Create an Eclipse project that is empty. 创建一个空的Eclipse项目。
    • point to all the worldwind dependencies (*.jar and *.dll files) 指向所有worldwind依赖项(* .jar和* .dll文件)
    • point to worldwind.jar 指向worldwind.jar
    • Then copy the examples folder into my Eclipse project. 然后将examples文件夹复制到我的Eclipse项目中。
    • Refactor all the packages that are listed as gov.nasa.worldwind.examples to examples. 将所有列为gov.nasa.worldwind.examples的包重构为示例。
    • Run the example ApplicationTemplate.java main. 运行示例ApplicationTemplate.java main。

When I do option (1.) I successfully compile/run with no errors. 当我做选项(1.)我成功编译/运行没有错误。

When I do option (2.) I successfully compile but get run time errors: 当我做选项(2.)我成功编译但得到运行时错误:

Apr 13, 2011 12:18:35 PM gov.nasa.worldwind.WorldWind createComponent
SEVERE: Exception while creating World Wind component gov.nasa.worldwind.cache.BasicDataFileStore
Apr 13, 2011 12:18:35 PM gov.nasa.worldwind.WorldWind createConfigurationComponent
SEVERE: Unable to create class for configuration key gov.nasa.worldwind.cache.BasicDataFileStore
Exception in thread "main" java.lang.ExceptionInInitializerError
    at gov.nasa.worldwind.awt.WorldWindowGLCanvas.<init>(Unknown Source)
    at Main2.main(Main2.java:15)
Caused by: java.lang.IllegalStateException: Unable to create class for configuration key gov.nasa.worldwind.cache.BasicDataFileStore
    at gov.nasa.worldwind.WorldWind.createConfigurationComponent(Unknown Source)
    at gov.nasa.worldwind.WorldWind.initialize(Unknown Source)
    at gov.nasa.worldwind.WorldWind.<init>(Unknown Source)
    at gov.nasa.worldwind.WorldWind.<clinit>(Unknown Source)
    ... 2 more
Caused by: gov.nasa.worldwind.exception.WWRuntimeException: Exception while creating World Wind component gov.nasa.worldwind.cache.BasicDataFileStore
    at gov.nasa.worldwind.WorldWind.createComponent(Unknown Source)
    ... 6 more
Caused by: java.lang.NullPointerException
    at gov.nasa.worldwind.cache.BasicDataFileStore.<init>(Unknown Source)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    ... 7 more

Due to licensing and configuration management issues, I would STRONGLY PREFER to go with Option (2.). 由于许可和配置管理问题,我强烈希望选择选项(2.)。 Does anyone know how to fix these run time errors seen above? 有谁知道如何解决上面看到的这些运行时错误?

Ok..These are my Eclipse project steps under Windows environment: 好的..这些是我在Windows环境下的Eclipse项目步骤:

  1. Create a new Eclipse project (a blank project is fine as long as it has the src folder) 创建一个新的Eclipse项目(只要它有src文件夹,空白项目就可以了)
  2. Create the lib folder under this project (under the root of the project folder) 在此项目下创建lib文件夹(在项目文件夹的根目录下)
  3. Put required libraries and DLLs into the lib folder: gluegen-rt.jar, jogl.jar, worldwind.jar, jogl.dll, gluegen-rt.dll, jogl_awt.dll, jogl_cg.dll 将所需的库和DLL放入lib文件夹: gluegen-rt.jar, jogl.jar, worldwind.jar, jogl.dll, gluegen-rt.dll, jogl_awt.dll, jogl_cg.dll
  4. copy the sample HelloWorlWind.java into the src folder 将示例HelloWorlWind.java复制到src文件夹中
  5. Add all JARs in the lib folder into the Referenced Libraries tree by right-clicking on each jar and select Build Path > Add to Build Path 通过右键单击每个jar并选择Build Path > Add to Build Path ,将lib文件夹中的所有JAR添加到Referenced Libraries树中
  6. Right-click on jogl.jar in the Referenced Libraries tree and select Build Path > Configure Build Path . 右键单击Referenced Libraries树中的jogl.jar ,然后选择Build Path > Configure Build Path It will pop up Properties dialog box 它会弹出Properties对话框
  7. In Properties dialog box, go to Libraries tab and expand jogl.jar tree 在“ Properties对话框中,转到“ Libraries tab然后展开“ jogl.jar
  8. Select Native library location and click Edit button on the right. 选择本Native library location ,然后单击右侧的“ Edit按钮。 It will popup Native Library Folder Configuration dialog box. 它将弹出Native Library Folder Configuration对话框。
  9. Set the lib folder as the location path by clicking on Workspace... button. 通过单击Workspace...按钮将lib文件夹设置为位置路径。

Then, run HelloWorlWind.java . 然后,运行HelloWorlWind.java It will display the glorious Worldwind Earth without any exception! 它将毫无例外地展示辉煌的Worldwind Earth!

Take note: a few Worldwind example apps don't terminate the JVM after you close the GUI window. 请注意:关闭GUI窗口后,一些Worldwind示例应用程序不会终止JVM。

For the ApplicationTemplate.java to work, make sure to copy the required dependencies: 要使ApplicationTemplate.java正常工作,请确保复制所需的依赖项:

  • ClickAndGoSelectListener.java ClickAndGoSelectListener.java
  • LayerPanel.java LayerPanel.java

I have no problems from doing exactly what you describe in option 2, it works fine. 我完全按照你在选项2中描述的那样做了没有问题,它运行正常。 When using a freshly downloaded copy of the WorldWind Java source code, you should do an Ant Build it before using the WorldWind.jar file. 使用新下载的WorldWind Java源代码副本时,应在使用WorldWind.jar文件之前执行Ant构建。 The WorldWind.jar file is not always upto date and can cause conflicts when being used. WorldWind.jar文件并不总是最新的,并且在使用时可能会导致冲突。

Basically what you describe from your actions is this: It works when it is using the source code, and that it fails when it is using the compiled code. 基本上你从你的行为中描述的是:它在使用源代码时起作用,并且当它使用编译的代码时失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM