June 15, 2014

Working with Java Jar files

1.  Create a normal Java project


































2. Create a class with the necessary methods with static declaration as shown below.












3. Once free of errors, click file > export and click 'JAR file' from the options shown

































4. Select the project and click finish in the following screen
































5. Now the jar file contains the the class files and is ready to be used in any project. To check out how it's working create a separate project and use the method as shown below. Right click > properties on the newly created project























6. Click 'Add External JARs ' and add the created jar in your project.
























7. The added JAR appears as shown in the 'Referenced Libraries'











8. Now use it in your project by directly invoking the method name without instantiating the MathLib class as shown below

1 comment: