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
55 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 by Vardhan
• 12,740 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
• 67,660 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,050 points
61 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,050 points
847 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 in Java by Sirajul
• 39,540 points
116 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,540 points
188 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,050 points
57 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
82 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
55 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,540 points
95 views
0 votes
1 answer

Unable to Run the .java file

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

answered Jan 10 in Java by Omkar
• 67,660 points
50 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 in Java by Omkar
• 67,660 points
1,230 views