Home > Software design >  Jar File Not Opening When Double Clicked
Jar File Not Opening When Double Clicked

Time:01-20

I am having a small issue when trying to run Jar files on another application. I create a simple code that opens a JFrame it runs when I double click on my PC but if I send it over to another PC, double clicking it does not do anything. It only opens up if I type java -jar yourjar.jar, how would I fix so that it opens the JFrame window when the jar is double clicked? JRE is installed on both environments

CodePudding user response:

To open a jar file in Windows, you must have the Java Runtime Environment installed. Alternatively, you can use decompression software, such as an unzip utility, to view the files in the jar archive.

You can also view, extract, run, and create JAR files with the Java Archive Tool provided as part of the Java Development Kit (JDK) included in the Oracle Java SE Development Kit. The Java Archive Tool is a command-line utility and here are the commands associated with the different capabilities:

To view a JAR file - jar tf jar file To extract a JAR file - jar xf jar file To run a JAR file - java -jar app.jar To create a JAR file - jar cf jar file input file(s) NOTE: If you are looking to extract the contents from a JAR file, you can use various decompression utilities, such as Corel WinZip (Windows), Corel WinZip Mac (Mac), RARLAB WinRAR (Windows), and 7-Zip (Windows).

Open and view .JAR files with File Vi

CodePudding user response:

This is well known issue with .jar files.

what we can do is try to right-click on the .jar file and Open With If some other program listed as the default program then If a Java Runtime is listed, you can open with it, and make it the default program to run with.

That is

 Right Click ->  Properties -> Change -> C:\Program Files\Java\jre7\bin\javaw.exe

this path may vary based on jre installation location.

  •  Tags:  
  • Related