Execute java file in windows

How to Run JAR Files on Windows 10 — 4 Ways [MiniTool Tips]

JAR files are commonly used on Windows computers. Hence, do you know how to run .JAR files on Windows 10? This post from MiniTool shows how to run JAR files on Windows 10. In addition, you can visit MiniTool to find more Windows tips and solutions.

What Are JAR Files?

A JAR is a package file format typically used to aggregate many Java class files and associated metadata and resources, such as text, images,etc. into one file for distribution. JAR files are archive files that include a Java-specified manifest file. They are built on the ZIP format and typically have a .jar file extension.

However, do you know how to run .JAR files on Windows 10? If no, keep on your reading, and the following part will show you how to run JAR files.

Читайте также:  Array representation in python

How to Run JAR Files on Windows 10?

In this part, we will show you how to run .JAR files with several different ways.

Way 1. Add Java to Windows

The first way you can try to open JAR files is to add Java to Windows. Without it, Java apps will not run on Windows and the JAR files also will not be opened.

So, in order to run .JAR files, you need to add JAVA to Windows. Now, here is the tutorial.

  1. Open Command Prompt.
  2. Next, type java -version in the Command Line window and hit Enter to continue. It will show you the further details of Java version on your computer.
  3. If there is no Java on your computer, click here to download the latest one.
  4. Then run it on your computer.

download Java

After all steps are finished, you can run .JAR files through the JAVA app.

Way 2. Open JAR Files with JAVA Platform SE Binary

In order to run JAR files, you can also choose to run it through the JAVA Platform SE Binary.

  1. Right-click the JAR file and select Open with from the context menu.
  2. Then select Choose another app and then select it to open with Java Platform SE binary.
  3. Check the option Always use this app to open Jar files.
  4. Then press OK to continue.

After all steps are finished, you can open JAR files on Windows 10 through the JAVA Platform SE binary.

Way 3. Open JAR Files with Command Prompt

Besides the above method, you can also run .JAR files through the Command Prompt.

  1. Open Command Prompt as administrator.
  2. Type the command – java –jar c:\path\to\jar\file.jar in the Command Line window and hit Enter to continue. Please replace the c:\path\to\jar\file.jar with the actual path and file title of the JAR you need to run in Windows.

Then, it will open the executable JAR file so long as it contains manifest file to specify the applications entry point.

Way 4. Add a Third-Party JAR Executor

As for how to run JAR files, you can use the third-party JAR executor and there are various JAR executors on the market. So, in order to run the JAR file, you can download a third-party JAR executor. After that, you can open the JAR file successfully.

Final Words

To sum up, as for how to run.JAR files, this post has introduced 4 ways. So, if you want to run .Jar files on Windows 10, you can try these ways. If you have any better idea to run .JAR files, you can share it in the comment zone.

About The Author

Tina is a technology enthusiast and joined MiniTool in 2018. As an editor of MiniTool, she is keeping on sharing computer tips and providing reliable solutions, especially specializing in Windows and files backup and restore. Besides, she is expanding her knowledge and skills in data recovery, disk space optimizations, etc. On her spare time, Tina likes to watch movies, go shopping or chat with friends and enjoy her life.

Источник

How to Run JAR files on Windows

JAR files are Java Archive files. It is a Zip version of Java Files that includes images, java class, audio, or other files, when the developer deploys the entire project, it saves classes and images files that are used in the Java project in the compressed form as a JAR (Java Executable File). JAR makes an archive for resources and classes. Additionally, it can restore or manipulate individual resources or classes from an archive. The JAR file content may be uncompressed using different tools such as WinZip, 7-Zip, or Windows default tool.

This write-up demonstrates the method to create and run a JAR file on windows. The following learning outcomes are expected:

    • Create a JAR File on Windows
    • Executing a JAR Files on Windows Using CMD?
    • Executing a JAR Files Using a Batch File?

    Create a JAR File in Windows

    The JAR is a Java executable compressed file that contains a Java project consisting of the images, code, and all the necessities in a project. To create a simple JAR file, follow up the listed steps:

    Step 1: Open Windows Command Prompt

    Search for “CMD” in the “Startup” menu and open Windows Command Prompt:

    Step 2: Open Java Project Folder

    Utilize the “cd” command to open the Java project folder in which you want to store java files in the form of a JAR file:

    We have used the “dir” command to list down the files inside the folder that are going to be compressed in a jar file:

    Step 3: Create JAR File

    We want to execute all java files in the form of a JAR file. For this purpose, we have utilized the provided command:

    The -cf option is the alias of “–create” and “–file” used to create the java file “Newjarfile”:

    Visit the directory where you have created JAR file or use “dir” command to check whether the JAR file is created or not:

    You can see that we have successfully created a JAR file in Windows.

    Method 1: How to Run JAR Files on Windows Using CMD?

    The JDK enables us to execute JAR files directly on the Windows operating system with the help of some commands. To execute the JAR file user can double click on it. But sometimes, this technique may not work due to some minor change in setting. We can execute it manually. Let’s check out how to run the JAR file on Windows:

    Step 1: Open Command Prompt

    Open the Command Prompt from the “Startup” menu by typing “Command Prompt”:

    Step 2: Run the JAR File

    Execute the provided command to run the JAR file from the command line:

    Here, you can see we have successfully run the JAR file from Command Prompt:

    Method 2: How to Run JAR Files Using a Batch File?

    Sometimes the JAR file is not executed by double clicking on it. Therefore, we can utilize a batch file to execute the JAR file on Windows. The batch file executes the command in a similar manner as the command prompt. But in the batch file, we can execute a collection of commands sequentially. It is mainly used to load and run programs. To run a JAR file using a batch file, utilize the provided instructions.

    Step 1: Create an Executable Batch File

    Here, we will be creating a batch file to run JAR file. To execute the JAR file, follow the listed instructions:

      • Create a simple text document. For this purpose, right-click anywhere in the Java project folder where you have created the JAR file.
      • Move the pointer on the “New” option and select “Text Document” from the displayed option.

      Rename the text file and also replace the file extension “.txt” with “.bat” to save the file as a batch script. The batch script is a simple text file that is used to run different commands in sequence:

      Edit the file and paste the following command into a batch script. After that, press “Ctrl+S” to save changes. Java is used to execute to run java project, the “-jar” option specifies that we want to execute the JAR file:

      Step 3: Run Jar file

      Double click on the batch script to run JAR file on Windows:

      We have effectively described the method to run JAR files on Windows.

      Conclusion

      To run JAR files, you can use the command “java -jar .jar” in Command Prompt. However, you can create a batch file and save the command “jar -cf ” in the batch file. Simply, run the batch file to get the output of the JAR file. This post aimed to demonstrate a method for JAR files execution on windows. For a better understanding, we have also demonstrated the method to create a JAR file.

      About the author

      Rafia Zafar

      I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.

      Источник

      How to Run Java Program?

      Java Course - Mastering the Fundamentals

      At first, check that Java is installed in your system and the path is properly set then we will see how to run the java program. If Java is not installed on the system or path is not defined properly, then we can’t run any Java programs on our system. After the JDK installation, compiling and running the java program is very easy.

      A java file is compiled using the javac command which generates a platform-independent bytecode that can be executed in any machine by a Java Virtual Machine (JVM). The bytecode is executed using the java command which executes the bytecode and produces the result.

      How to Run a Java Program Using Command Prompt and Notepad?

      Here we will be using Notepad and Command Prompt to run the Java programs. Let’s see the process step-by-step:

      • Create a new folder.
      • Go to the folder, and make the new Java file in that folder.
        • Press Alt+D, and just type Notepad there.
        • Notepad will open, now paste the java code given below in the Notepad and save it with extension java.

        Let’s see the above steps with images:

        Step 1: I have used the code given below for performing all the below operations. Open the Notepad and copy this code in the notepad and save that file with the extension .java.

        You can see in the below images that, I have written the java code and saved it as test.java. Now the new file will be created with the name test.java.

        Create a Notepad named folder

        Open a Notepad file and copy the Java Code

        Save the file with name test.java

        Step 2: You can see that inside the Art folder, there is a java file with the name test.java.

        Java file is there in the folder

        Step 3: Now press Alt+D , and you will get into the above search bar.

        type CMD

        Step 4: Type CMD and press enter key.

        press enter key

        Step 5: You can see that the CMD is open. Now type javac test.java , as you can see in the below image.

        Type javac test.java command

        Step 6: You can see that a new file has been created with the .class extension . The name of the file would be the name of the class you have used inside your program. In my case, I have used the Scaler as a class name.

        new file has been created

        Step 7: Now again, open the cmd and type the command java Scaler as you can see in the below image.

        Open the cmd and type the command java Scaler

        Step 8: At last, you will see that the content of the file has been displayed .

        Content of the file has been displayed

        The javac Command

        Java programs are compiled using the javac command. It takes .java files as input and generates bytecode.

        The java Command

        The java command is used to execute Java bytecodes. It takes bytecode as input, executes it, and outputs the result.

        Conclusion

        • We have seen how to run a Java program using notepad .
        • Create the Java file using Notepad and run it using java and javac commands.
        • Java programs are compiled using the javac command.
        • The java command is used to execute the Java bytecode generated as a result of compilation.

        Источник

Оцените статью