This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes how to access the resources(methods,fields of a class) of a jar file in other program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "how to access the resources(methods,fields of a class) of a jar file in other program" Watch "how to access the resources(methods,fields of a class) of a jar file in other program" New topic
Author

how to access the resources(methods,fields of a class) of a jar file in other program

Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
I wrote a program wch contains a single method.I compiled the program and kept the class file in a folder(package)and created the jar file. Now i want to access the method of a class in the jar file from another program. How can i achieve this.


Abhishek
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

Put the jar file in the runtime classpath on your system (and/or add it to the classpath for the program you are using to start the application). You also will need it as an available library for building. Is this a java program?
[ March 29, 2006: Message edited by: Scott Selikoff ]

My Blog: Down Home Country Coding with Scott Selikoff
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

First off, I'd prefer to discuss this in the forum instead of private e-mails so others may benefit.

Is the program you are trying to call it from a java program? You should read up on classpaths (just ask google) and it will tell you a lot about them. Otherwise, if it is not a java program, then you may have limited ability to use a method since java programs generally require a running jvm to be invoked from. Please tell us more about your situation after reading about classpaths.
 
jQuery in Action, 2nd edition
 
subject: how to access the resources(methods,fields of a class) of a jar file in other program