Results 1 to 9 of 9
  1. #1
    aswinkavali is offline Member
    Join Date
    May 2014
    Posts
    10
    Rep Power
    0

    Default How to use a function in a jar file in another java file?

    Hi,

    I need to use a some function which is already there in a jar file in another java. could you please post one code showing on how to do that?

    for example,

    Consider a jar file created from a java file in which only one constructor is there say SHA (String message).

    I need to use this SHA method in another java file.

    How to import the jar file to the existing java file? import .....

    thanks,
    Ashwin

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: How to use a function in a jar file in another java file?

    Put the jar file on the classpath and your code will be able to use classes from the jar file.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    aswinkavali is offline Member
    Join Date
    May 2014
    Posts
    10
    Rep Power
    0

    Default Re: How to use a function in a jar file in another java file?

    Hi Norm,

    Is it possible to add the jar file in class path in Eclipse IDE?

    What can i do if i am not using those IDE and i am using command prompt for compiling and running java file?

    Thanks,
    Ashwin

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,049
    Rep Power
    6

    Default Re: How to use a function in a jar file in another java file?

    How about: learn basic Java? Working with libraries is as fundamental as it gets and is documented in dozens of books and hundreds of articles, blogs, tutorials and manuals on the internet. It is also documented in the online help of your Eclipse IDE.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: How to use a function in a jar file in another java file?

    i am using command prompt for compiling and running java file
    Read the doc for how to use the javac and java commands.

    Java Platform Standard Edition 7 Documentation
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    aswinkavali is offline Member
    Join Date
    May 2014
    Posts
    10
    Rep Power
    0

    Default Re: How to use a function in a jar file in another java file?

    Thanks. The normal way of calling methods from another jar wont work here in my case. but i was able to do it viewing the code of already existing cases.

    --Ashwin

  7. #7
    aswinkavali is offline Member
    Join Date
    May 2014
    Posts
    10
    Rep Power
    0

    Default Re: How to use a function in a jar file in another java file?

    Nice try!

    --ashwin

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: How to use a function in a jar file in another java file?

    Can you explain how you solved the problem?
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    aswinkavali is offline Member
    Join Date
    May 2014
    Posts
    10
    Rep Power
    0

    Default Re: How to use a function in a jar file in another java file?

    i will tell only the overview, since those files are confidential to one organization.

    A main jar file is there and a X file which will use functions from this jar file. For using these function we need to import these classes and functions.

    import com.....main.funct(parameters).

    inorder to use our own java functions we need to use some specific functions from these main jar file and then compile with main jar in class path.

    For example,

    import com...main.function1;
    .
    .
    .
    public static function(datatype variable, parameter) (this datatype has already been created in the main jar)

    and then if we need to use this user defined function then we need to import this into working file,
    import returntype class.function(parameters);

    ....
    .
    .
    .
    class.function(variables)

    regards,
    Ashwin

Similar Threads

  1. Replies: 1
    Last Post: 01-10-2012, 12:49 PM
  2. Replies: 0
    Last Post: 03-01-2011, 10:41 AM
  3. passing an entire file to a c++ function
    By P5music in forum New To Java
    Replies: 3
    Last Post: 10-01-2010, 04:49 PM
  4. Save File Function
    By Jovan in forum New To Java
    Replies: 5
    Last Post: 06-02-2010, 02:27 AM
  5. Hiding a method or function using PHP file
    By Raj Singh in forum Eclipse
    Replies: 1
    Last Post: 08-09-2007, 07:26 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
  •