有时,您会发现以 .jar 文件而不是通常的.exe文件形式分发的应用程序或游戏。您不能只双击JAR文件来运行应用程序。那么(How),如何打开JAR文件?
Java曾经是一种流行的编码语言,用于创建免费软件游戏和应用程序。即使是现在,许多免费软件应用程序都以 .jar 文件的形式分发,Windows 本身并不支持这些文件。本文将引导您了解如何在您的计算机上打开JAR文件。
什么是 JAR 文件?
Internet浏览器使用Java来提供动态浏览体验。游戏(Games)和其他交互式小程序使用Java编码,可以在任何平台上运行。
但是有一个小问题。需要多个HTTP请求才能下载该小程序运行所需的所有资产,从而减慢了加载时间。更好的方法是将所有文件打包成一个Java可以访问以运行应用程序的文件。
这正是JAR文件的内容。受WinZip的启发,JAR是Java使用的文件存档,用于保存从多媒体文件到代码的任何内容,并且可供Java小程序访问。
在您的 PC 上安装 Java
打开JAR(JAR)文件最直接的方法是在您的计算机上安装Java 运行时环境(Java Runtime Environment)( JRE )。这不仅使您能够打开.jar文件,而且还使您的系统能够运行Java应用程序。
- 下载(Download)最新的JRE版本,前往Oracle 官方下载页面(Oracle’s official download page)。
- 向下滚动(Scroll)以找到适合您操作系统的安装包。有在线和离线安装程序。在线安装将在安装过程中简单地下载必要的文件,而离线版本首先下载所有必要的文件,然后开始安装。
- 运行下载的文件以开始在您的计算机上安装JRE 。接受许可协议以进行设置。通常,安装程序会自动删除旧版本的JRE,但如果需要,您可以手动删除。(do that manually)
- 完成安装后,您可以在 PC 上运行任何Java应用程序,包括(Java)JAR文件。
请注意,这仅允许您的计算机使用下面提到的方法打开JAR文件,但它不会关联(JAR).jar扩展名,这意味着如果您尝试双击JAR文件,Windows仍然不知道要打开什么处理文件。
查看以下部分以了解如何在安装JRE后打开(JRE)JAR文件。
从命令提示符打开
需要明确的是,这根本不是一种不同的方法。您仍然需要在计算机上安装Java才能从命令提示符打开JAR文件,因此先执行该步骤。(JAR)
使用上一节中的过程在计算机上安装Java后,您可以使用命令提示符打开JAR文件。
- 以管理员身份打开命令提示符。(Command Prompt)在搜索栏中键入cmd以找到该应用程序。
- 输入命令java -jar C:pathtofile.jar,其中“pathtofile”是相关文件的路径。您可以将文件复制到 C 驱动器本身以使其更容易,您只需输入文件名即可。
- 执行该命令后,Windows将使用JRE来解释JAR文件。您现在应该看到Java应用程序正在运行。
除非您想要的应用程序作为可执行Java文件分发,否则每次运行JAR文件时都需要执行所有这些步骤。
提取为存档
JAR文件是具有花哨名称的存档数据。当然,它们适用于Java应用程序,但 .jar 文件仅将它们压缩并归档到单个包中,因此您可以使用任何领先的文件提取工具(如WinRAR 或 7-Zip )提取(WinRAR or 7-Zip)JAR文件。这将让您看到包的内容,但如果您想运行应用程序本身,您仍然需要JRE 。
- 下载7-Zip 安装程序(7-Zip installer)以提取 .jar 文件。
- 运行下载的 .exe 文件以在您的计算机上安装 7-Zip。
- 导航到包含您要提取的JAR文件的目录。(JAR)
- 右键单击(Right-click)该文件,选择 7-Zip,然后选择Extract All。
- JAR文件将被提取到目录中。
在Windows 10上打开JAR 文件(JAR File)的最佳方法是什么?
JAR文件通常是打包成单个文件的Java应用程序。(Java)要运行它们,您需要在 PC 上安装Java 运行时环境。(Java Runtime Environment)由于JRE可以免费下载,因此这是让 .jar 文件在您的Windows计算机上运行的最简单方法。
另一方面,如果您只想查看JAR归档文件的内容而不实际运行它,则始终可以使用文件提取工具。7-Zip或WinRAR等应用程序(Apps)可以轻松提取.jar文件的内容。
How to Open a JAR File on Windows
Occasionally, you find аpplіcationѕ or games distributed as .jar files instead of the υsual .exe file. You can’t just double-click on a JAR file to run the app. How, then, do you open a JAR file?
Java used to be a popular coding language to create freeware games and applications. Even now, many freeware apps are distributed as .jar files, which Windows does not natively support. This article will walk you through ways to open JAR files on your computer.
What Is a JAR File?
Internet browsers used Java to offer a dynamic browsing experience. Games and other interactive applets were coded using Java and could run on any platform.
But there was a small problem. It took multiple HTTP requests to download all the assets required for that applet to work, slowing down its load time. A better approach would be to package all the files into a single file that Java could access to run an application.
And that’s exactly what the JAR file is. Inspired by WinZip, JAR is a file archive used by Java to hold anything from multimedia files to code and is accessible to Java applets.
Install Java on Your PC
The most straightforward method to open a JAR file is to install the Java Runtime Environment (JRE) on your computer. Not only does this give you the ability to open .jar files, but it also makes your system capable of running Java apps.
- Download the latest JRE version, head to Oracle’s official download page.
- Scroll down to find the right installation package for your operating system. There are both online and offline installers. The online setup will simply download the necessary files during the installation while the offline version downloads all necessary files first and then will start the installation.
- Run the downloaded file to begin the installation of JRE on your computer. Accept the license agreement to get the setup underway. Usually, the installer will automatically remove older versions of JRE, though you can do that manually if needed.
- A completed installation allows you to run any Java app on your PC, including JAR files.
Note that this only allows your computer to open JAR files using the method mentioned below, but it doesn’t associate the .jar extension, which means that if you attempt to double-click a JAR file, Windows still wouldn’t know what to do with the file.
Check the following section to learn how to open a JAR file once JRE has been installed.
Open From Command Prompt
To be clear, this isn’t a different method at all. You still need to have Java installed on your computer to open JAR files from the command prompt, so that step comes first.
Once you’ve installed Java on your computer using the process in the last section, you can then use the command prompt to open JAR files.
- Open Command Prompt as an administrator. Type cmd in the search bar to locate the application.
- Enter the command java -jar C:pathtofile.jar , where “pathtofile” is the path of the file in question. You can copy the file to the C drive itself to make it easier, allowing you to enter just the file name.
- Upon execution of the command, Windows will use the JRE to interpret the JAR file. You should now see the Java application running.
Unless the application you want is distributed as an executable Java file, you’ll need to execute all these steps each time you run a JAR file.
Extract as an Archive
JAR files are archived data with a fancy name. Sure they’re meant for Java applications, but a .jar file only compresses and archives them into a single package, thereby letting you extract JAR files using any leading file extraction tool like WinRAR or 7-Zip. This will let you see the contents of the package, though you’ll still need the JRE if you want to run the application itself.
- Download the 7-Zip installer to extract .jar files.
- Run the downloaded .exe file to install 7-Zip on your computer.
- Navigate to the directory containing the JAR file you wish to extract.
- Right-click on the file, select 7-Zip, and then select Extract All.
- The JAR file will be extracted into the directory.
What is the Best Method To Open a JAR File on Windows 10?
JAR files are usually Java applications packaged into a single file. To run them, you need to have the Java Runtime Environment installed on your PC. As JRE is free to download, this is the easiest way to get .jar files working on your Windows computer.
On the other hand, if you just want to look at the contents of the JAR archive but not actually run it, you can always use a file extraction tool. Apps like 7-Zip or WinRAR can easily extract the contents of a .jar file.