Question

I am working in NetBeans 7 with Python script using Jython. I am trying to build a NASA WorldWind example.

I have added JARs to the classpath, including the one that contains gov.nasa.worldwind.

The code crashes, saying

  Traceback (most recent call last):
  File "C:\Users\wrightky\Documents\NetBeansProjects\WW\src\ww.py", line 4, in <module>
  import gov.nasa.worldwind as wwj
  ImportError: No module named gov

I have both added the JAR with "gov" to the classpath and even added the JAR to the Python package manually, under which I can see gov.nasa.worldwind.

I could add my code but not sure if it's relevant.

Why would this happen?

Was it helpful?

Solution 2

I was able to solve this problem in Eclipse, and I am not sure of the analogous solution in NetBeans though it isn't important to me at this point. Simply importing a JAR file is not enough to claim its functionality. It must be added to the Interpreter Libraries.

Window -> Preferences -> PyDev -> Interpreter - Jython -> New Folder (I did New Jar/Zip(s) as well, I assume either would solve the issue) and point to the directory (or JAR).

OTHER TIPS

From your question it's not entirely clear whether you're compiling a Java class file or something from Python, but if it is Java you should know that you can't do import X as Y in Java. If you have conflicting class names, you'll just have to always use the fully-qualified class name (ie gov.nasa.wordwind.SomeClass) every time you reference it.

See this question for more details: Change Name of Import in Java, or import two classes with the same name

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