Skip to main content

How to create a jar file using eclipse in 3 easy steps

A jar file is a Java ARchive file that contains many java .class files as well as other resource files in a compressed format.
It is similar to a tar or zip format.

Here are three simple steps with illustrations to create your jar file in Eclipse IDE.



Step 1 : Create your java class(es)

I have written a java class HelloWorld.java in Eclipse in a package called HelloWorld as shown below.




Step 2 : Choose the export file format

Now I want to put entire project in a jar file.
Right-click on the package and select export.





Now select under Java icon JAR as shown.




Step 3 : Specify the jar file name and location

I give the jar file name as C:\amol\HelloWorld.jar as shown




I check 'Export generated class files and Resources' and 'compress the contents of jar file' checkboxes.
Thats it.
Now just click finish and your jar file will be created at the given location.


CGTUXEU3CDMS

Comments

Popular posts from this blog

How to convert a CSV file to XLSX

I wrote this utility for a friend of mine who wanted to convert large (~50MB) CSV files to XLSX. The CSV files had comma "," as a delimiter. I have used apache poi utility in this program. https://www.apache.org/dyn/closer.lua/poi/release/RELEASE-NOTES.txt This code uses SXSSFWorkbook class. The SXSSFWorkbook class uses "BigGridDemo" strategy, where only portions being processed are kept in memory. There are temporary files created which store the rest of the temporary data. setCompressTempFiles() method allows these temp files to be compressed. The size of these files can get quite large. The data to be converted was UTF-8 encoded data. So, we are using  OutputStreamWriter, where we specify the encoding of the data. If you do not need the encoding, just remove that parameter from the constructor call of OutputStreamWriter. The system where this ran, supported Java 7, so have not used features in java 8, such as try with exceptions. import java.io.*; im...

How to take a full webpage screenshot using AShot library

AShot library Ashot library by yandex.ru is something which I recently found. It can be used for multiple browsers. It is very simple to use. Just add maven dependency in your java code. < dependency > < groupId > ru.yandex.qatools.ashot </ groupId > < artifactId > ashot </ artifactId > < version > 1.5.2 </ version > </ dependency > </ pre > Then call the takeScreenshot() function,as shown below and you have a screenshot file. new AShot () .shootingStrategy( ShootingStrategies . viewportPasting( 100 )) .takeScreenshot(myWebDriver); You could even select specific html elements and take their screenshots. WebElement webElement = webDriver . findElement( By . cssSelector( "#element_to_be _captured" )); new AShot () .takeScreenshot(myWebDriver, webElement); All this can be found at below repository. https://github.com/yandex-qatools/ashot Know of any more libraries ...

Five most useful spring modules

  Java Spring framework is one of the popular java frameworks. A thread on 5 commonly used spring modules 1. Spring Boot and Spring MVC These modules makes it easy and quick to create stand-alone, production-grade Spring based Applications that you can "just run". Example Use:- A RESTful service with self-container server. 2. Spring Batch This module is used to build batch applications that need to recurrently process large volumes of data. Features: Chunk based processing, retry, skip Example Use:- Everyday, read data of daily trades from database and update the credit on customer's accounts. 3.Spring Data Provides a spring based programming model for accessing data. This module has very powerful features and supports wide range of databases. Example Use:- Read, Write data from PostgreSQL for your application. 4.Spring Cloud Provides tools for developers to quickly build some of the common patterns of distributed systems. Libraries for Service registration and discovery,...