JAR (Java Archive File) is an archive format that stores elements of a program written in the Java language. Most often, files with this extension are mobile games and applications. On your computer, you can view the contents of such an archive and/or try to run the JAR as an application.

First, let's look at several programs for opening a JAR archive. This way you can make sure that it contains everything you need to run this application, and also make the required changes.

Method 1: WinRAR

When it comes to archives, the WinRAR program comes to mind for most users. It works great for opening a JAR file.


Please note that there is a folder "META-INF" and file "MANIFEST.MF", which should be stored in it. This will allow the JAR file to be implemented as executable.

Find and open required archive You can also use the built-in WinRAR file browser.

If further work is planned with the contents of the archive, unarchiving will be required.

Method 2: 7-Zip

Support for the JAR extension is also provided in the 7-Zip archiver.


Method 3: Total Commander

An alternative to the programs mentioned can be a file manager Total Commander. Because its functionality includes working with archives; opening a JAR file will not be difficult.


Ways to run JAR on a computer

If you need to run a JAR application or game, you will need one of the special emulators.

Method 1: KEmulator

The KEmulator program is an advanced Java emulator that allows you to configure various application launch parameters.

On mobile phones, control was carried out using the keyboard. In KEmulator you can enable its virtual analogue: click "Reference" and select "Keyboard".

It will look like this:

If you wish, in the program settings you can set the correspondence between the phone keys and the computer keys.

Please note that a file will appear in the JAR folder "kemulator.cfg", which specifies the operating parameters of this application. If you delete it, then all settings and saves (if we are talking about the game) will be deleted.

Method 2: MidpX

The MidpX program is not as functional as KEmulator, but it gets the job done.

Once installed, all JAR files will be associated with MidpX. This can be understood by the changed icon:

Double click on it and the application will be launched. Wherein virtual keyboard is already integrated into the program interface, but you cannot configure control from the PC keyboard here.

Method 3: Sjboy Emulator

Another simple option for running JAR is Sjboy Emulator. Its main feature is the ability to select skins.


The keyboard is also integrated here.

So, we found out that JAR can be opened not only as a regular archive, but also run on a computer through a Java emulator. In the latter case, it is most convenient to use KEmulator, although other options also have their advantages, for example, the ability to change the window design.

Java applications and games for mobile phones are still finding their users, although they are gradually being replaced by products developed for the popular Android or iOS operating systems. Java MIDlets have a JAR or JAD extension and are designed primarily to be launched from a phone. However, often users need to run the jar file on the computer first. And for this, there are several utilities that perform the function of J2ME emulation (Java 2 Mobile Edition, a special modification of the Java language (Java), adapted for mobile phones) and launching java midlets.

Let us immediately note that some emulators require a Java virtual machine installed on the system. To install it, download the Java SE JRE version for Windows.

In the simplest case, just click on the JAR file to see the result of executing the Java script. For example, this is how we will see a small application Minesweeper (Author Marat Kenzhebekov), designed in the form:

Every serious mobile phone manufacturer has its own software development kits (SDKs), which usually include emulators. But today we will look at universal emulators that allow you to run any jar files on your computer.

MidpX Java Application Emulator

The MidpX emulator allows you to quickly launch a JAD or JAR file on your computer with just one click. This can be either a java game or any application for mobile phone. Browser users Internet Explorer can use context menu and select item Link MidpX.

For other users who prefer other browsers, it is better to first download the jar file, and then select the item in the Explorer context menu Open with – Midp2Exe Compiler.

Once the file is received, MidpX generates an executable EXE file and runs it automatically. The result of executing the exe file, which was originally a JAR file, we see in the window with the image cell phone. To control an application or game, there are standard keys found on any mobile phone. Although the program allows you to use the control keys of a regular computer keyboard or the number keys on the side keyboard to control the application. There are also buttons to stop, restart or start the application. In the status bar you can find out the frame rate. MidpX settings will help you change the brightness and contrast, change the transparency and volume of the music.

The generated EXE file, by the way, is saved by the program in the same folder where the original JAR file is located. We also note the possibility of installing a separate utility for converting jar files into exe called MIDP2EXE, however, working with it is not very convenient, since all operations are performed through the command line. There is also a graphical shell GUIMidp2Exe.exe. It allows you to convert jar files and entire directories, shows full information about the selected jar file and icon, can generate a JAD file, launches the generated exe file for testing, extracts all file resources, including pictures, text and sounds into the temporary folder Test in the folder with the emulator (after closing all files are deleted), saves screenshots mobile games in JPG.

Characteristics:
Interface language: Russian, English, etc.
File size: 1.9 MB
License: free
Link to office website: kwyshell.myweb.hinet.net/Download/MidpX/MidpX.exe

Java game emulator SJBoy

We position SJBoy specifically as a game emulator. This is due high speed emulation and no less good quality, allowing you to run java games without any problems. SJBoy provides our choice of one of four models phones: two Nokia, SonyEricsson and Motorola. Depending on the selected model, the skin of the front panel of the mobile phone changes. After installation, no extra manipulations with jar files will be required. Just select a file in the list and double-click to run it. SJBoy will pick up the file and immediately begin emulating the java application. In most cases, it will be most convenient to use the SJBoy emulator.

Control in the menu is performed both by clicking on the drawn phone keys, and by control and numeric keys computer keyboard. Among useful functions You can note the possibility of creating a screenshot (menu Tools – Snapshot). The image is saved in a BMP file.

Characteristics:
Interface language: English
File size: 1 MB
License: free
Link to office website: files.ddvhouse.ru/soft/96_sjboyemulator.rar

How to extract data from a jar file

In some cases, users do not need to run the jar file, but rather open it to see the contents. Many people know that a jar file, although it has such an extension, is actually a zip archive. Accordingly, you can view the contents of the jar file in any archiver that supports the ZIP format. Just open the jar file and select necessary files and extract them from the archive. In the presence of file manager In Total Commander, you can rename the jar file extension to zip, then enter the archive and see its contents, and later extract the data.

The JAR format is familiar to many users firsthand. It is an archive file created based on the JAVA programming language. However, even users who have encountered the JAR format in their work do not always know how to open it. Let's try to fill this gap.

JAR file: how to open it?

Since this type of file is originally created using the JAVA language, the most logical assumption for viewing or editing the content is to use the appropriate platform.

But do not confuse this format with files for mobile systems. In order for a JAR file to become executable, it must contain metadata in its structure in the form of an embedded MANIFEST.imf file.

However, the object of this type itself is initially associated with the environment Java Runtime Environment, so if one is installed on your computer, the file will open automatically. This applies in particular to the Jarsigner tool from the Java SDK.

Mobile systems

IN mobile systems You can also find JAR. How to open it on your phone? Yes, you don’t need to do anything. These objects are application installers, however, as a rule, installation is performed using additional file installer instructions in JAD format.

When you run the installer, it will be installed in automatic mode similar to how such processes occur in computer systems (though without using the “Installation Wizard” or selecting a location for the application to be installed). If for some reason the JAVA environment is not supported by the phone or simply does not work, you can often open it using the MidpX emulator.

JAR file: how to open it on a computer?

WITH computer systems the situation is even simpler. Not to mention the above-mentioned development environment, you can use familiar tools.

So, we have a file in JAR format. You can understand how to open it on a computer or laptop if you remember that this is actually an archive. In other words, any of today's well-known archivers will do. Unpacking operations can be done quite simply using programs like WinRAR, WinZIP, 7-Zip and the like.

You can often find highly targeted utilities that allow you to change the archive format, turning the file into executable program in the form of a regular “executable file”. Among these, the most famous application is JAR2EXE Converter.

Finally, sometimes this format may contain data about themes or add-ons for some popular web browsers (Thunderbird, Mozilla Firefox etc.) The theme is simply applied to the design, and the user does not see the opening of the file as such (only the appearance browser).

JAR stands for Java ARchive - Java Archive. If you don’t go into too much detail (which, in general, often happens in reality), the JAR file is a regular ZIP file with some additions. The main task of this archive is to store files with classes. Those. packages/directories (we talked about them in the Packages section), which contain class files, are archived and the JVM can use them in a more convenient (compact) form.
The benefit is obvious - in real projects you are unlikely to be limited to using class libraries only from the JDK - most likely you will connect hundreds (if not thousands) of classes that were created to solve specific problems. If all this huge amount were stored on disk in the form of class files, then it is easy to understand how inconvenient and cumbersome it is. Java developers have proposed a completely elegant solution - you can include archive files that contain thousands of compiled classes. Which is, of course, more convenient than dragging all the directories with all the files into each project.
For example, you can look at the JAVA_HOME/jre/lib directory - there is a very important archive there - rt.jar. This library contains almost all the classes we looked at - String, JFrame, JButton, Date, Object. You can open it using any archiver.
When viewing the contents of a JAR file, you will sooner or later notice the directory META-INF. It contains a file MANIFEST.MF. I highly recommend that you read about it in Working with Manifest Files: The Basics. The file allows you to expand functionality - in addition to the usual set of classes, the JAR file can perform functions electronic signature, support for versioning, connecting libraries to the archive itself, defining a class to run (which contains a method main). In this article, I do not set myself the goal of analyzing these possibilities, so we will leave it for the future. Let's get down to the basics of using JAR files.

Creating a JAR

Using the IDE

Almost all IDEs can create JARs. We will do this using NetBeans as an example; you can consider other IDEs yourself. Which is not always an intuitive task. Creating a JAR in NetBeans is very easy. To do this you need to take the following steps:

In the project directory you can see the directory dist which will contain the JAR file. As I mentioned, this process may look different in other types of IDEs. For example, in Eclipse this is done through export, and in IDEA - through the creation of artifacts. In this series of articles, I don’t plan to dwell on this in detail yet, although if I succeed, I’ll add it right here.

Using the utility jar

A JAR file can also be created using the jar utility, which is located in the JAVA_HOME/bin directory. This utility is discussed in some detail here: Creating a JAR File.
In the simplest version, you need to create classes in some directory, and then call this utility with the following command

jar cf<имя JAR-файла> <список входных файлов>

For example if I have a class edu/javacourse/jar/SayHello.class, then the creation command archive file With name say.jar would look like this:

jar cf say.jar edu/javacourse/jar/SayHello.class

jar cf say . jar edu/javacourse/jar/SayHello. class

Options "cf" mean: "c" - create, "f" - file. Well, then I think it’s obvious - the name of the archive file and the list of files. Moreover, you can specify many files in the list separated by a space, and you can also use a mask - the signs “*” and “?”. If you are not familiar with such signs, type “file masks use” into a search engine and enjoy your new knowledge.
To view the contents of a file, you can (as I said above) use almost any archiver or the command jar.exe like this

jar tf say. jar

In both cases (IDE or utility jar) a file will be created in the archive MANIFEST.MF. As I already wrote, it makes sense to read about additional properties JAR files. Because Everything in the documentation is written very well, I won’t bother with the translation. So let's move on to the next point in our journey through JAR files.

Connecting ready-made JAR files

Command line

So, I said that the main function of a JAR is to contain a set of classes in the form of class files. Now we need to understand how to include JAR files in the startup class so that the startup class can use the classes from the JAR file.
As you already well know, running a program in Java involves launching the JVM (for Windows this is java.exe, for Unix - java) and passing it the name of the class that you are going to run from the command line. For example, to run a class First in the package edu.javacourse.test must be in the directory within which the directory is located edu/javacourse/test type this command:

java edu.javacourse.test.First

javaedu. javacourse. test. First

As you can see, we passed the full name of the class we are going to launch as an argument. The JVM, in addition to the class name, accepts quite a lot of parameters that allow you to configure certain properties of the JVM. In this article we will look at a very important element - CLASSPATH- which is precisely used to connect JAR files.
Now we will go through the full cycle of creating a JAR file and connecting it without using an IDE - I am very sensitive to the programmer’s ability to use command line. Firstly, it shows that you really understand the essence, and secondly, this skill is simply very useful. For example, in Unix/Linux, it is much more convenient to do a lot of work on the command line, and some products contain utilities that can be launched from the command line. So let's get busy.
Let's create a directory JavaLesson(in principle, we have already created it in the Basic steps section. In this directory we will create a directory structure JarLib/edu/javacourse/jar. By using text editor let's create a file SayHello.java

package edu.javacourse.jar; public class SayHello ( public void sayHello() ( System.out.println("HELLO"); ) )

Now it's time for the command line. Run the “cmd” command (if you don’t remember, see the Basic Steps section). Go to the catalog JavaLesson/JarLib and first compile our file in it SayHello.java with this team

javac edu/javacourse/jar/SayHello.java

If everything worked out for you, then in the catalog JavaLesson/JarLib the file should appear say.jar.
Now let's write a small class that will use our class SayHello. IMPORTANT!!! For the “purity of the experiment”, let’s create this class in the directory JavaLesson. I suggest creating a class without using packages (although this should not be the rule - in real projects there is no need to create classes without packages). Here is our file UseHello.java, which will be located in the directory JavaLesson

import edu.javacourse.jar.SayHello; public class UseHello ( public static void main(String args) ( SayHello sh = new SayHello(); sh.sayHello(); ) )

public class UseHello

public static void main (String args) (

sh. sayHello();

Pay attention to the first line - in it we import the class SayHello. In method main we create an object and call its method. Our directory structure should look like this:

C\: JavaLesson JarLib edu javacourse jar SayHello.java UseHello.java

And we get the error:

C:\JavaLesson>javac UseHello.java UseHello.java:1: error: package edu.javacourse.jar does not exist import edu.javacourse.jar.SayHello; ^ UseHello.java:6: error: cannot find symbol SayHello sh = new SayHello(); ^ symbol: class SayHello location: class UseHello UseHello.java:6: error: cannot find symbol SayHello sh = new SayHello(); ^ symbol: class SayHello location: class UseHello 3 errors

C:\JavaLesson>javacUseHello. java

UseHello. java: 1: error: package edu. javacourse. jar does not exist

import edu . javacourse. jar. SayHello ;

SayHello sh = new SayHello();

symbol : class SayHello

location : class UseHello

UseHello. java : 6 : error : cannot find symbol

SayHello sh = new SayHello();

symbol : class SayHello

location : class UseHello

3 errors

The message in this case is quite informative - “UseHello.java:1: error: package edu.javacourse.jar does not exist” and “UseHello.java:6: error: cannot find symbol”. We didn't connect our class SayHello- the compiler doesn’t know where to get it from or where such a package/class comes from - edu.javacourse.jar.SayHello. Well - to paraphrase the classics - “Your word, comrade CLASSPATH.”
Obviously, we need to tell the compiler that it should use not only those JAR files that it already has - the same rt.jar- but also our JAR file. This is done using a special option when starting the compiler.

javac -cp JarLib/say.jar UseHello.java

javac - cp JarLib / say . jar UseHello . java

In this command we added the line -cp JarLib/say.jar. Part -cp says that it should be followed by a list of JAR files that contain the required classes. The list may include several files, separated by “;” for Windows, and “:” for Unix/Linux. For example, if I need to specify two files - say1.jar and say2.jar - located in the directory C:/Anton/Libraries, then the command (for Windows) would look like this:

javac -cp C:/Anton/Libraries/say1.jar;C:/Anton/Libraries/say2.jar UseHello.java

javac - cp C:/Anton/Libraries/say1. jar ; C:/Anton/Libraries/say2. jar UseHello . java

By the way, “-cp” is short for classpath— earlier it was necessary to write exactly this way, and now it is also possible.

javac -classpath C:/Anton/Libraries/say1.jar;C:/Anton/Libraries/say2.jar UseHello.java

javac - classpath C:/Anton/Libraries/say1. jar ; C:/Anton/Libraries/say2. jar UseHello . java

It is also important to note that CLASSPATH can include not only JAR files - it can include the path to the directory with .class files (again, several of them can be specified). If we had not created the JAR file say.jar, but used the compiled file SayHello.class from the catalog JarLib, then the command would look like this.

Archiving and unpacking are carried out using jar files. One of their important features is the ability to compress, eliminating losses. The .jar format allows for efficient document sorting and sending. Before you can learn how to open a jar file on your computer, you need to install and activate it to make it executable.

The jar format owes its name to the Java ARchive, from which it originates. Its main purpose is the development and distribution of add-ons designed for programs created by Mozilla.

How to open a jar file on a computer?

You can open a jar file on your computer quickly and easily by double-clicking on it with the mouse, after which you will select Windows system necessary program that allows you to cope with the task.

If the above action was not successful and did not lead to the opening of the jar file, the reason is that the necessary application program editing documents with this extension.

If the jar file is opened in the wrong program, the settings must be changed. To do this, it is necessary that the document contains a file MANIFEST.MF in the META-INF directory indicating the main class of the program, including the main method.

To view the contents of a jar archive, you can use any archiver with ZIP compression. Such a file can be launched using the MidpX Java application emulator. Another way is to convert it to .EXE format using the JAR2EXE Converter program.

Application Features

Before you can start using the jar file, you must open it using a compatible application, which you can choose from the following list:

  • Firefox
  • Thunderbird
  • SeaMonkey
  • Sunbird

Additions designed to work with Firefox browser. They provide significant expansion functionality browser and its configuration taking into account the personal needs that each user determines for himself.

For example, using add-ons you can:

  • download videos presented on popular video hosting sites
  • delete promotional materials from web pages
  • control the browser using gestures, etc.

The Mozilla Sunbird calendar application can be expanded with the use of add-ons. This application is designed to create a daily schedule and create tasks, the purpose of which is to alert at a specially set time.

Thunderbird is an excellent assistant that allows you to view email notifications, create new emails, filter spam, send mail back, etc. Add-ons help better compatibility Thunderbird with Microsoft tools provides more comfortable work with contacts, signatures for letters, etc.

Knowing useful information, you can start working with the jar file on your computer.