How To Run A .JAR File From Command Line?

436 Views
0 rating based on 0 reviews

When your computer is unable to start correctly, you need to use Safe Mode with Networking and try to figure out why it's not running what it should. That's why I'm going to show you how to turn on Safe Mode in Windows.

Run a .JAR File From Command Line

Are you wondering how to run a .JAR file from the command line? If your answer is yes, then you have come to the right page. In this article, you will learn what a .JAR file is and how to run it from the command line. Continue reading for more valuable information.

What is a .JAR File?

Before anything else, let’s first discuss what exactly is a .JAR file. .JAR is an abbreviation for Java Archive. It is a file format that is based on the ZIP file. It is commonly used to aggregate several files, but it can also be used as an achievement tool.

However, the main purpose of its development is to allow the requisite components of Java applets to be downloaded to a browser using a single HTTP transaction instead of opening a new one.

Executable .JAR Files

The Java 2 Runtime Environment installation program will register a default association with .JAR files on the Microsoft Windows system. This means that when you double-click the .JAR files on a computer, it will run automatically with Javaw-.JAR. At the same time, dependent extensions bundled together with the application will be automatically loaded. This ensures that users have easier runtime.

If you are wondering how to identify whether a .JAR file is executable, you can just follow these steps:

  1. Launch the Windows file Explorer.
  2. Click on View, then select Folder Option.
  3. Click on Files Type Tab.
  4. From here, you can see whether the .JAR file is executable or not.

Steps on How to Run .JAR File From Command Line

Before running a .JAR file from the command line, you first need to configure Java on the system. Here are the steps on how to write down an easy Java program:

  1. Create a new folder and name it as Gradle Workspace.
  2. Launch Notepad and start writing the Java script mentioned below:Java script mentioned below
  3. Save the file with the name “GradleDemo.java”.

After that, you will also need to create and set Gradle. Here are the steps on how to do this:

  1. Launch the Notepad.
  2. Select File and write this code: “Apply plugin: ‘java.”
  3. At this point, you will need to type in the specific class name so fill in the details if you do not declare the build.gradle file method, you will get an error when you try to run the executable .JAR file.

This is now the point where you will need to create a .JAR file. Here are the steps you need to follow:

  1. Press the Windows and R keys together, then type in “cmd.”
  2. Type in cd E:GradleWorkspace to find the Java file location.E:GradleWorkspace to find the Java
  3. Type in “Gradle build.” This common will commence creating the .JAR file with the build folder under the root folder name.

Now, you can start running the .JAR file using the command line. Here are the steps on how to do this:

Open the command line prom and look for the root folder.

Enter this command; java –.JAR ..JAR

Confirm the results that will appear.

There you have it, which are the steps on how to run .JAR files using the command line from scratch.

Final Words

Running a .JAR file from the command line might sound complicated. However, that is not exactly the case. It might be a little complex if you are doing and setting it up for the first time. But, eventually, you will get the hang of it.

Plus, with the information and steps mentioned above, the process can be very manageable. Just go over them and use it as a guide and you will find that it's quite straightforward.

Summary: Run a .JAR File From Command Line

  • Make a new folder.
  • Open a terminal window.
  • Navigate to the new folder.
  • Download the .JAR file for your project by clicking on the project name, then "releases".
  • Move your .JAR file into the new folder you made.
  • Type "cd" followed by a space. Drag the folder that contains your .JAR file onto the terminal window (this will automatically fill in the location). Press enter.
  • Type "java -jar", followed by a space and then drag in your .JAR file. Press enter. The jar should run and you can see what it does!