What is the meaning of purpose of this command: java -jar <some jar file>.jar ?

0 votes
Mar 21 in Java by Ishu
• 120 points
25 views

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
–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 by Vardhan
• 10,600 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 21 by Omkar
• 65,850 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,020 points
31 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,020 points
151 views
0 votes
1 answer

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

I think it is most useful as ...READ MORE

answered May 4, 2018 in Java by Akrati
• 3,150 points
44 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,520 points
98 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,020 points
30 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
46 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,280 points
23 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,520 points
56 views
+1 vote
1 answer

Unable to Run the .java file

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

answered Jan 10 in Java by Omkar
• 65,850 points
30 views
0 votes
1 answer

web.xml file is missing in my eclipse IDE

Very simple. You will find Deployment Descriptor ...READ MORE

answered Nov 27, 2018 in Java by Omkar
• 65,850 points
29 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.