Results 1 to 4 of 4
  1. #1
    puifais is offline Member
    Join Date
    Feb 2017
    Posts
    1
    Rep Power
    0

    Default How to call a function within a .jar file from another program?

    I'm writing a script that is supposed to call a function from an open-source plug-in script called IHC Toolbox1.jar. I decompiled this .jar file using JD GUI1 so that I can see all the files associated with the file. There are many .class and a few .java stuff inside the .jar file. I sifted through all the codes to find the command I would like to run. It's called runCommand and seems to be nested inside the class buttonCommand. I don't know Java but I thought in Jython/Python, I could just say:

    Java Code:
    import buttonCommand
    buttonCommand.runCommand('color',impRGB,'')
    But it's not finding runCommand because apparently runCommand doesn't exist in the class buttonCommand.

    I think the problem here is that I don't know Java and do not understand how it's organized. Would anyone please give me a pointer? I've included some screenshots here. I circled the class and the function in question. Also circled the corresponding "Color" button that the Jython script is suppose to tell the plug-in to execute. I just need to know how to call this function inside a .jar file. I'm happy to write my code in Python or Java or IJ1 Macro but I just do not know how to interact with the function inside this .jar script. I think this has to do with objects being private, public, static, or instance...but I don't know these concepts of object oriented programming and haven't been able to figure it out :(
    Attached Thumbnails Attached Thumbnails How to call a function within a .jar file from another program?-4291a83a30c9206f2366934cae8252b3a754b168.png  

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: How to call a function within a .jar file from another program?

    How to call a function within a .jar file from another program?
    Put the jar file on the classpath, then in your code: define an instance of the class that has the method and use the reference to that instance of the class to call the method.
    Last edited by Norm; 02-24-2017 at 11:46 PM.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: How to call a function within a .jar file from another program?

    If this was open source then I would have expected to be able to find the source code and not have to decompile it. That would be a little more reliable.

    Anyway, looking at that code both the class and the method are package private, so are not intended to be used outside of the package they are part of.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: How to call a function within a .jar file from another program?

    Quote Originally Posted by puifais View Post
    I think the problem here is that I don't know Java and do not understand how it's organized. Would anyone please give me a pointer?
    The Java™ Tutorials

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. How to call a VBA function in Java
    By gorgon777 in forum New To Java
    Replies: 0
    Last Post: 01-20-2014, 01:24 PM
  2. call a function dynamically
    By bigjo in forum New To Java
    Replies: 3
    Last Post: 01-18-2013, 03:56 PM
  3. Call a function via URL
    By cali_guy_0024 in forum New To Java
    Replies: 7
    Last Post: 04-10-2011, 05:04 AM
  4. function call error
    By peter_thm in forum New To Java
    Replies: 2
    Last Post: 01-13-2010, 12:57 PM
  5. how to call dll file in java program
    By santhosh_el in forum AWT / Swing
    Replies: 6
    Last Post: 06-12-2009, 09:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •