Expand my Community achievements bar.

SOLVED

Jar

Avatar

Level 1

Screenshot 2023-05-04 111224.png

How to convert the type of the file from JAR to Executable Jar file.

 

Thanks&Regards,

Anantharamulu.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

hi @Anantharamulu_G ,

You can convert a regular JAR file into an executable JAR file by following these steps:

1. Create a file named MANIFEST.MF in the same directory as your JAR file. Add the following contents to the file:

 

Manifest-Version: 1.0
Main-Class: com.example.MainClass​

 

 

 

2. Open a command prompt or terminal window.Navigate to the directory containing your JAR file and the MANIFEST.MF file and Run the following command:

 

jar cfm myapp.jar MANIFEST.MF com/example/*.class

 

 

 

3. To test the executable JAR file, Run the following command to start your application:

 

java -jar myapp.jar

 

 

 

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

hi @Anantharamulu_G ,

You can convert a regular JAR file into an executable JAR file by following these steps:

1. Create a file named MANIFEST.MF in the same directory as your JAR file. Add the following contents to the file:

 

Manifest-Version: 1.0
Main-Class: com.example.MainClass​

 

 

 

2. Open a command prompt or terminal window.Navigate to the directory containing your JAR file and the MANIFEST.MF file and Run the following command:

 

jar cfm myapp.jar MANIFEST.MF com/example/*.class

 

 

 

3. To test the executable JAR file, Run the following command to start your application:

 

java -jar myapp.jar

 

 

 

Avatar

Employee Advisor

Hi @Anantharamulu_G ,

 

I think you are facing some issues with opening this JAR, it is executable by default. the problem here seems to be here ".jar" in your filename. Could you try after removing it? 

I have seen this problem on Windows, where sometimes adding an extension makes it unusable. (Check you view setting of windows).

 

Also, try to open this file using the command prompt using

java -jar <youraemjar>

 

Hope this helps!

 

Regards,

Nitesh

Avatar

Community Advisor

@Anantharamulu_G 

Try 

Right-click the .jar file >> click Properties >> In the general tab, click Change besides open with: >> click More Apps >> scroll down, click Look for another app on the PC >> browse to Java installation directory > bin > select  "javaw"