What is the meaning of purpose of this command java -jar some jar file jar

0 votes
Mar 21, 2019 in Java by Ishu
• 120 points
2,619 views

2 answers to this question.

–1 vote
java -jar <name>

I think this is used when that particular JAR file is needed as part of the execution of a command. 

answered Mar 21, 2019 by Vardhan
• 13,150 points
You are partially right @Vardhan. This command is used to execute a JAR file. But JAR itself is a Java application in a compressed format.
0 votes

JAR (Java Archive) file is a package file format that contains many classes, metadata, and resources like image, audio etc., that is necessary for a Java application. A JAR file is a Java application compressed in a single file which contains all the resources required to run a Java application. 

The command mentioned in the question is used to run a JAR file. When you have written a Java program, the command to execute it is:

java <name of the java program file>

Similarly, when you want to execute a Java application that is present as a JAR file, you use the below command:

java -jar <some jar file>.jar

Here, you have to replace <some jar file> with the name of the JAR file. Suppose you want to execute Example.jar, then the command would be:

java -jar Example.jar
answered Mar 22, 2019 by Omkar
• 69,220 points

Related Questions In Java

+2 votes
1 answer

What is the meaning of "this" keyword in Java?

public class MyThisTest { private int ...READ MORE

answered Oct 10, 2018 in Java by Daisy
• 8,140 points
885 views
0 votes
2 answers

What is the use of toString method in Java and how can I use it ?

Whenever you require to explore the constructor ...READ MORE

answered Aug 23, 2018 in Java by Daisy
• 8,140 points
4,103 views
0 votes
2 answers

What is the use of @Override annotation in Java ? When do we use it ?

@Override annotation is used when we override ...READ MORE

answered Aug 14, 2019 in Java by Sirajul
• 59,230 points
3,471 views
0 votes
1 answer

What is the concept of Immutability for strings in Java ? Why are strings immutable ?

According to Effective Java, chapter 4, page 73, ...READ MORE

answered May 11, 2018 in Java by Rishabh
• 3,620 points
1,601 views
0 votes
2 answers

What is the use of final class in java?

In Java, items with the final modifier cannot be ...READ MORE

answered Oct 5, 2018 in Java by Daisy
• 8,140 points
1,889 views
0 votes
1 answer

What is the use of StringBuilder in java?

If you use String concatenation in a ...READ MORE

answered Jun 19, 2018 in Java by Akrati
• 960 points
804 views
0 votes
1 answer

What is the use of assert keyword in java?

Java assertion feature allows the developer to ...READ MORE

answered Jun 28, 2018 in Java by scarlett
• 1,290 points
861 views
0 votes
1 answer

What is the equivalent of the C++ Pair<L,R> in Java?

In a thread on comp.lang.java.help, Hunter Gratzner ...READ MORE

answered Jul 4, 2018 in Java by Rishabh
• 3,620 points
1,074 views
0 votes
1 answer

Unable to Run the .java file

You have to enter the commands as ...READ MORE

answered Jan 11, 2019 in Java by Omkar
• 69,220 points
794 views
0 votes
1 answer

Is there a way to mask the password from java user input that comes from Scanner class and System.out.Println()?

You can use the console class to do so. ...READ MORE

answered May 27, 2019 in Java by Omkar
• 69,220 points
11,099 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP