Jython classpath question

Discussion in 'Python' started by Tennessee James Leeuwenburg, Jul 17, 2003.

  1. Hi all,

    Sorry for the newb question, but Googling and FAQing didn't work. Is it
    correct that Jython can only access Java classes which are inside JAR
    archives in the JYTHON_HOME directory? IT doesn't seem to be documented. I
    ask because I want to do groovy prototyping using Jython, and save myself
    a lot of coding overhead to try something a little out-of-the-box.

    I have a working directory where all my code lives, and because my app is
    under rapid development, I would prefer to avoid creating a JAR file every
    time I want to do some Python scripting?

    What do people suggest I do?

    Thanks,
    -Tennessee
     
    Tennessee James Leeuwenburg, Jul 17, 2003
    #1
    1. Advertising

  2. Tennessee James Leeuwenburg

    Marijan Guest

    No it is not true. If you can access your class from java, in jar file
    or not, (it has to be in the classpath), you can access it from jython.
    I've been playing with jython and java a while ago, but I can remember I
    had to do a little trying out, before I figured out how to access some
    java class. As far as I can remember you can have more java classes in
    one *.class file, so it is possible that you have to write:

    import classfilename.classname

    or similar, but do not blame me if I am wrong here, as far as I can
    remember I had to to some trying out in this direction.

    There is also a jython mailing list, and two books about jython.


    "Tennessee James Leeuwenburg" <> wrote
    in message news:p...
    > Hi all,
    >
    > Sorry for the newb question, but Googling and FAQing didn't work. Is

    it
    > correct that Jython can only access Java classes which are inside JAR
    > archives in the JYTHON_HOME directory? IT doesn't seem to be

    documented. I
    > ask because I want to do groovy prototyping using Jython, and save

    myself
    > a lot of coding overhead to try something a little out-of-the-box.
    >
    > I have a working directory where all my code lives, and because my app

    is
    > under rapid development, I would prefer to avoid creating a JAR file

    every
    > time I want to do some Python scripting?
    >
    > What do people suggest I do?
    >
    > Thanks,
    > -Tennessee
     
    Marijan, Jul 17, 2003
    #2
    1. Advertising

  3. On Thursday 17 July 2003 03:29, Tennessee James Leeuwenburg wrote:
    > Hi all,
    >
    > Sorry for the newb question, but Googling and FAQing didn't work. Is it
    > correct that Jython can only access Java classes which are inside JAR
    > archives in the JYTHON_HOME directory? IT doesn't seem to be documented. I
    > ask because I want to do groovy prototyping using Jython, and save myself
    > a lot of coding overhead to try something a little out-of-the-box.
    >


    No you can import a java .class file. Just make sure it's on the python path
    (sys.path) if both .py and .class files are in the same directory then you
    need do nothing... if not then you could add the directory containing the
    java class files to python sys.path like so:

    import sys

    sys.path.append("/path/to/java/class/files")


    for more information / alternative suggestions look at :-

    http://www.jython.org/docs/registry.html

    Regards
    Martin
     
    Martin Franklin, Jul 17, 2003
    #3
  4. Thanks All.

    -Tennessee
     
    Tennessee James Leeuwenburg, Jul 18, 2003
    #4
  5. I can now import every class except the one which I would most like to
    import.

    The fully-qualified classname is au.gov.bom.aifs.dv.dv.
    I can import anything else from the au.gob.bom tree, and also other things
    from the dv tree such as dv.LayerManager. It's just dv.dv that is causing
    hassles.

    Are there any pitfalls or required naming conventions that I should be
    aware of?

    Thanks,
    -Tennessee
     
    Tennessee James Leeuwenburg, Jul 18, 2003
    #5
  6. Never mind,

    It was barfing on a dependant class that wasn't in the classpath. I was
    just misreading the error message.

    Thanks guys,
    -T
     
    Tennessee James Leeuwenburg, Jul 18, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Flip
    Replies:
    3
    Views:
    7,409
    Tony Morris
    Feb 9, 2004
  2. David McNab
    Replies:
    0
    Views:
    520
    David McNab
    Apr 9, 2004
  3. HK
    Replies:
    0
    Views:
    441
  4. Divya Prakash
    Replies:
    0
    Views:
    464
    Divya Prakash
    Dec 19, 2006
  5. Pinegar, Kent T

    FW: [Jython-users] Jython Licensing Question

    Pinegar, Kent T, Jul 24, 2008, in forum: Python
    Replies:
    0
    Views:
    372
    Pinegar, Kent T
    Jul 24, 2008
Loading...

Share This Page