aspose file tools*
The moose likes Beginning Java and the fly likes How to create my own API Libraries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to create my own API Libraries" Watch "How to create my own API Libraries" New topic
Author

How to create my own API Libraries

buntha Choudhary
Ranch Hand

Joined: Jul 03, 2009
Posts: 136

I created few components in Swing and I want to dump all these in a library file so that all the methods can be reused through intellisense in eclipse.
For example, on using any 3rd party api, we have been provided with some libraries and then we could reuse all the methods available by import the files.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14342
    
  22

Just put your compiled classes in a JAR file. Someone who wants to use your components then adds that JAR file on his or her classpath (or to the project dependencies in Eclipse).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
buntha Choudhary
Ranch Hand

Joined: Jul 03, 2009
Posts: 136

Thanks
Adam Richards
Ranch Hand

Joined: Nov 03, 2005
Posts: 135
Some general guidance on building libraries: Since a library is generally ignorant how it will be called, it can't make many assumptions on how to handle (or even if it should handle) errors. So as a general rule, I recommend not trying to catch very many exceptions in library classes (exept perhaps to display the message on System.out). Just pass along the exception to the calling app - only he knows the context & can make an informed decision on what to do with errors. Trying to to be too clever in error handling is a common beginner's mistake when developing API's for the first time.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39814
    
  28
Adam Richards wrote: . . . exceptions . . . (exept perhaps to display the message on System.out). . . .
Good advice, but you display error messages on System.err, surely?
Adam Richards
Ranch Hand

Joined: Nov 03, 2005
Posts: 135
Sure, or wherever it makes sense or local policy dictates
buntha Choudhary
Ranch Hand

Joined: Jul 03, 2009
Posts: 136

I will keep in mind
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create my own API Libraries