Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


question regarding code completion...

  • I'm new to pydev & could use some help with getting the object introspection to work with imported java objects in a jython project.

    So far I've
    1)put my java library development 'bin' area as a source file in the project's python path
    2)referenced my java project in the jython project's preferences

    code completion works great on import statements, such as:

    from com.bitaplus.CurveAnalytics import *

    but when I initialize an object from the imported java library, I can't get the methods to appear on typing a '.' ...

    Am I missing something?

    Running the script accesses the object fine & I get the expected result.

    Many thanks,


    • Fabio Zadrozny
      Fabio Zadrozny

      Ok, let's see some simple example...

      If you do:

      from java.lang import String
      String. | <-- do you get the completions here or not?

      Did you configure your project to be a jython project?

      Have you checked the getting started guide to see if you configured your your project and pythonpath correctly? -- http://www.fabioz.com/pydev/manual.html



    • Thanks for the quick response Fabio.

      I followed the instructions on the manual as best I could.

      The project IS a jython project

      I can't get code completeion to work on the simple example either.

      I tried
      from java.lang import String


      without success.
      I also tried:

      foo = String()
      without success

      Thanks again,


      • Fabio Zadrozny
        Fabio Zadrozny

        Do you have some error in your error log?

    • Thanks Fabio.


      I checked the error & it turns out I didn't have a python interpreter installed in the system preferences. I had specified a Jython.jar file for the Jython Interpreter because since It's a jython project I didn't think i needed a python interpreter... obviously i did.

      Now the simple case works with java.lang.String

      The case with my own imported libraries, however, doesn't. The editor thinks I'm making a mistake every time I use one of the objects from the external library.

      In the following snippet of code

      from java.lang import String
      from com.bitaplus.CurveAPI import *
      foo = CurveAPIManager()
      bar = String()

      the third line is underlined in red, as though it's a mistake. This strikes me as a bit strange because the code completion works beautifully with the second line, e.g. after typing 'from com.' a dropdown box appeard with my entire library tree.

      Any thoughts?

      The code runs without errors, by the way.

      Many thanks again!


      • Fabio Zadrozny
        Fabio Zadrozny

        Actually, are you ABSOLUTELY sure that your project is set as Jython and not as a Python project?
        In the project type in the project properties is it marked as jython 2.1?

        Because here in my install, you don't need to have the python interpreter set if you set the jython interpreter.



    • One more thing... I've got one error in the error log: "ERROR getting completions."


      • Fabio Zadrozny
        Fabio Zadrozny

        And what's in the details of that error?

    • Yes. Just Checked.

      1) clicked on the project.
      2) went to project/properties
      3) in the opened window clicked on 'Pydev - project type' and the radio button says Jython 2.1...



      • Fabio Zadrozny
        Fabio Zadrozny

        Which version of pydev are you using?

    • Eclipse V3.1.1
      PyDev V1.0.6

      I've cut & pasted the details from the error log  below:

      ERROR getting completions.
      java.lang.RuntimeException: The shell is still not connected, so, it is an invalid state to try to write to it.
          at org.python.pydev.editor.codecompletion.shell.AbstractShell.write(AbstractShell.java:611)
          at org.python.pydev.editor.codecompletion.shell.AbstractShell.getTheCompletions(AbstractShell.java:810)
          at org.python.pydev.editor.codecompletion.shell.AbstractShell.internalChangePythonPath(AbstractShell.java:802)
          at org.python.pydev.editor.codecompletion.shell.AbstractShell.getImportCompletions(AbstractShell.java:758)
          at org.python.pydev.editor.codecompletion.revisited.modules.CompiledModule.setTokens(CompiledModule.java:108)
          at org.python.pydev.editor.codecompletion.revisited.modules.CompiledModule.<init>(CompiledModule.java:72)
          at org.python.pydev.editor.codecompletion.revisited.ModulesManager.getModule(ModulesManager.java:450)
          at org.python.pydev.editor.codecompletion.revisited.ProjectModulesManager.getModule(ProjectModulesManager.java:246)
          at org.python.pydev.editor.codecompletion.revisited.ProjectModulesManager.getModule(ProjectModulesManager.java:230)
          at org.python.pydev.editor.codecompletion.revisited.AbstractASTManager.getModule(AbstractASTManager.java:264)
          at org.python.pydev.editor.codecompletion.revisited.AbstractASTManager.getBuiltinCompletions(AbstractASTManager.java:547)
          at com.python.pydev.analysis.visitors.OcurrencesVisitor.<init>(OcurrencesVisitor.java:130)
          at com.python.pydev.analysis.OcurrencesAnalyzer.analyzeDocument(OcurrencesAnalyzer.java:32)
          at com.python.pydev.analysis.builder.AnalysisBuilderThread.doAnalysis(AnalysisBuilderThread.java:159)
          at com.python.pydev.analysis.builder.AnalysisBuilderThread.run(AnalysisBuilderThread.java:118)



    • fabio.

      Thanks for your help.

      I've figured out a solution... I created a JAR file from my java project & included it in the project instead of the java library bin folder. That seems to have done the trick for the code completion. Only drawback is I need to repack the JAR file every time I change the library. It's totally outweighed though by the convenience of the code completion!

      Odd thing with my experience was that the even though the code completion didn't work when I pointed the project at the Java Library Bin folder, the script WOULD execute without runtime errors.

      All the best,


      • Fabio Zadrozny
        Fabio Zadrozny

        Well I guess that the problem is that jython did not get the updates, but good you found an alternative...

        I do have to think about it better how to deal with those things when you're doing the development in java and in jython at the same time... I guess I should parse java files too for code-completion purposes instead of using a shell as I do now.



      • Currently stuck with the same problem - what do you mean by "I included [a jarfile(?)] in the project"?

        Do you mean you impored the jarfile? (I tried so, but this fails...)

        While one is able to set a classpath for java projects, this possibility is completely missing in a pydev project - at least it's not obvious where to do so.(One can't browse used java classes as well...)

        Help welcome :-)

        Greetings, Dirk