Free Online Courses for Software Developers - MrBool
× Please, log in to give us a feedback. Click here to login
×

You must be logged to download. Click here to login

×

MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

×

MrBool is totally free and you can help us to help the Developers Community around the world

Yes, I'd like to help the MrBool and the Developers Community before download

No, I'd like to download without make the donation

The process of Java Jar File Creation

The jar file is generally created with different types of process in different software and java editor platform base. In this article we will discuss about the Java jar file creation process in details.

The java programming model works with the jar file creation process. This jar file generally created with different types of process in different software and java editor platform base. We can also create the jar file through Blue Java environment, Eclipse, Net beans and also other systems. To open a jar file in Windows we will either need a copy of the Java Runtime Environment to run the file, or decompression software such as an unzip utility if we want to view one of the files within it. A jar file is much like a zip file formation model which contains multiple files within it.

Here we are discussing about BlueJava and Eclipse base technology and this technology also supports the jar file creation.

Process to create a jar file step by step process in Blue Java:

Now I will discuss the procedure that supports to create jar file in the BlueJava platform through step by step procedure.

At first click on Project menu -> Click to Create jar file option.

Showing create jar option

Figure 1: Showing create jar option

After clicking the Create jar file option the following window will be open- > Check on Include Bluej project files. Select a *.java file given below window

Showing include option

Figure 2: Showing include option

After that just Go to Continue button and the following window will be opened and save the file with a given name.

Showing jar file

Figure 3: Showing jar file

Jar File Name

After that click on create button option and automatically it will generate the file.

Double click on the file and run it.

This point should be remembered that we can also transfer *.jar file to *.exe file.

Process to create a jar file step by step process in Eclipse:

This article adapts to user about Java and the processing in your computer. This is also not an Eclipse article. Generally these types of article just cover the different ways of work processing in Eclipse platform.

This article outlines how to manually set-up a Processing project in Eclipse. We are recommending that check out the Eclipse Plug-in prolapsing that is designed to make working with Processing in Eclipse which is much easier for the users.

Step I. Download Eclipse in your System

This is the first step for the creation process of the jar file in the Eclipse software so we have to download the "Eclipse IDE for Java Developers" from http://www.eclipse.org/downloads/ URL. When we run first the eclipse IDE (Integrated Development Environment) it will generate a workspace directory. This is the directory where we can store our project files, so pick something reasonable that should be remembered.

Step II. Install Eclipse Process

This is the next process after installation of the Eclipse software. Just double click on the exe file and install in the system.

Step III. New project creation Process

If we want to see a Welcome screen, just go fast and close it. Then go to File --> New Project and select "Java Project." Click Next. Enter our project name (for example, "mrbool") and select "Finish."

Step IV. Import the libraries for processing the project

The Eclipse IDE doesn't know anything about the processing so we have to go and get the processing libraries ourselves.

Another way to do this is by pointing Eclipse to Processing the "core library" directory and it is sometimes a good idea to copy the necessary processing files into the project folder itself so that everything stays together and goes to the: File --> Import --> General --> File System.

Click next and Click browse and find the processing application. On Windows we will then want to look inside the directory called "lib" but if we are working in the Mac system(for Processing 2.0) we will have to go inside the application's "package contents": Processing->Contents->Resources->Java. Select the file "core.jar" inside the "library" folder.

Click Finish

Figure 4: Click "finish."

We should now see "core.jar" listed under our project in the package explorer.

Selct the jar

Figure 5: Selct the jar file

Right-click on the file and select Build Path -> Add to Build Path

The "core.jar" file should now appear with a jar icon. This point should be noted that the right-click option will only show up in the "Package Explorer."

Showing  package explorer

Figure 6: Showing package explorer

Step 4. Create a class and write our code

Go to the: File -> New -> Class

Enter a class name like "mrbool" and click finish. Eclipse may think about the use of the default package which is always discouraged. Basically the package in Java provides a nice means for organizing our classes and this is a good thing for us also. However for just getting this example working and we can easily remove our idea from the concept of the package in the java programming model structure.

After selecting finish button we will see the following code here:

public class mrbool 
{
	………….
	………….
}

Eclipse is being nice and filling in the class definition for us. Basically when we want this class to be a processing sketch then we have to add some code which is given below:

  • Import the core Processing library: "import processing.core.*;"
  • Extend PApplet. PApplet is the parent processing class that allows us to have access to all the Processing goodies.
  • Write setup() and draw() This is also "public" for these Processing functions.

Step IV. Run Procedure of the jar file

Go to: Run -> Run As -> Java Applet

Generally we are often going to run our code as a Java application which is better than applet and turn on processing present mode. We can do this by adding a main() function to our code.

 public static void main(String subrata[]) 
{
    PApplet.main(new String[] { "--present", "mrbool" });
  }

This point should be noted that the String "mrbool" must match the name of our class and if it is in a package should include the package i.e. packagename.mrbool.

Once we have added the main() function, we can also select the option in the following way: Run -> Run As -> Java Application

JAR file creation through Java commands

Now I will discuss the following few commands that can be used to create/view/modify/execute a JAR file using Java command line utilities and Java Virtual Method.

Create a JAR file through the coding procedure

Syntax: jar cf JAR_FILE_NAME FILE_NAMES_OR_DIRECTORY_NAME

Example: jar cf mrbool.jar d:\Java\mrbool

View contents of a JAR file

Syntax: jar tf JAR_FILE_NAME

Example: jar tf mrbool.jar

View contents with detail of a JAR file

Syntax: jar tvf JAR_FILE_NAME

Example: jar tvf mrbool.jar

This point should be noted that we have used v (verbose) option to see the detail of JAR.

Extract content of JAR file

Syntax: jar xf JAR_FILE_NAME

Example: jar xf mrbool.jar

Extract specific file from JAR file

Syntax: jar xf JAR_FILE_NAME FILE_NAME(S)_FROM_JAR_FILE

Example: jar xf mrbool.jar Test1.class

Update a JAR file

Syntax: jar uf JAR_FILE_NAME FILE_NAMES_FROM_JAR_FILE

Example: jar uf mrbool.jar Test1.class

Executing a JAR file

Syntax: java -jar JAR_FILE_NAME

Example: java -jar mrbool.jar

Create an executable JAR file

In order to create the executable JAR file, one of the classes that we include in our JAR must be a main class.

Create a text file called MANIFEST.MF using any text editor and copy following content in it.

  • Manifest-Version: 1.0
  • Main-Class: mrboolClass

Also note that we have to specify fully qualified class name in the system.

After that we should use the following command to create an executable JAR file.

jar cvfm mrbool.jar MANIFEST.MF FILE_NAMES_OR_DIRECTORY_NAME

Conclusion

After discussing the above scenario we can take a decision that jar file creation is very much important for our software development architecture. Because when we wish to send software to our respective client then we must think that it should be easily integrated in the project to the client machine. So executable file or jar file takes a very standard role in the development area. It is true that if we do not use the jar file or executable file in our programming model then it will be difficult during application development and integration.



Website: www.techalpine.com Have 16 years of experience as a technical architect and software consultant in enterprise application and product development. Have interest in new technology and innovation area along with technical...

What did you think of this post?
Services
[Close]
To have full access to this post (or download the associated files) you must have MrBool Credits.

  See the prices for this post in Mr.Bool Credits System below:

Individually – in this case the price for this post is US$ 0,00 (Buy it now)
in this case you will buy only this video by paying the full price with no discount.

Package of 10 credits - in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download few videos. In this plan you will receive a discount of 50% in each video. Subscribe for this package!

Package of 50 credits – in this case the price for this post is US$ 0,00
This subscription is ideal if you want to download several videos. In this plan you will receive a discount of 83% in each video. Subscribe for this package!


> More info about MrBool Credits
[Close]
You must be logged to download.

Click here to login