In this post, you will know how to create a jar file using net-beans , Eclipse and using ant scripts in easy and straightforward way.
Net-beans.
Step 1: you had to right click on the project
Step 2: Click Clean and Build.
Step 3: check out the Jar that already created under the project folder (./dist)
PS. to change the entry man class. choose it and edit in MANIFEST.MF
Main-Class: package.MainClass
Eclipse :
Batch File way (not easy):
Step 1: prepare your files. place all files you wan
Step 2:Create a manifest file that will point to the main Class
(Ex manifest.mf) contains :
Manifest-Version: 1.0
Main-Class: loggingForm
Step 3: Create Batch File in the same folder (new text file and rename it by Ex: luncher.bat) ..
jar cf myjar.jar manifest.mf loggingForm.class
jar : refer to the jar.exe . which copile the jar file.
c : refer that you want to create JAR file.
f : you want to specify the file name,
myjar.jar : the name of the crated jar.
manifext.mf : include the main class.
logginigForm: the list of the classes that will be compiled ( to include more Classes, separate by space.)
Net-beans.
Step 1: you had to right click on the project
Step 2: Click Clean and Build.
Step 3: check out the Jar that already created under the project folder (./dist)
PS. to change the entry man class. choose it and edit in MANIFEST.MF
Main-Class: package.MainClass
OR
change the Build.xml and add below tag.
<manifest file="MANIFEST.MF">
<attribute name="Main-Class" value="package.MainClass" />
</manifest>
Eclipse :
- In the Package Explorer, you can optionally pre-select one or more Java elements to export.
- Either from the context menu or from the menu bar's File menu, select Export.
- Expand the Java node and select JAR file. Click Next.
- In the JAR File Specification page, select the resources that you want to export in the Select the resources to export field.
- Select the appropriate checkbox to specify whether you want to Export generated class files and resources or Export Java source files and resources. Note: Selected resources are exported in both cases.
- In the Select the export destination field, either type or click Browse to select a location for the JAR file.
- Select or clear the Compress the contents of the JAR file checkbox.
- Select or clear the Overwrite existing files without warning checkbox. If you clear this checkbox, then you will be prompted to confirm the replacement of each file that will be overwritten.
- Note: The overwrite option is applied when writing the JAR file, the JAR description, and the manifest file.
- Click Finish to create the JAR file immediately.
Batch File way (not easy):
Step 1: prepare your files. place all files you wan
Step 2:Create a manifest file that will point to the main Class
(Ex manifest.mf) contains :
Manifest-Version: 1.0
Main-Class: loggingForm
Step 3: Create Batch File in the same folder (new text file and rename it by Ex: luncher.bat) ..
jar cf myjar.jar manifest.mf loggingForm.class
jar : refer to the jar.exe . which copile the jar file.
c : refer that you want to create JAR file.
f : you want to specify the file name,
myjar.jar : the name of the crated jar.
manifext.mf : include the main class.
logginigForm: the list of the classes that will be compiled ( to include more Classes, separate by space.)
Related Topics:
- Click here to Know how to run the produced jar by Double click
No comments:
Post a Comment