Jump to content

How to run a .jar file manually - Step by step guide for beginners


OutCraft

Recommended Posts

I often say to people "Run the jar file manually and post the output here" and they don't know how to do this. So here is a step by step guide for beginners with examples and explanations so that everyone understands it ;)

 


First you need to know what a cmd, also called command prompt or command line is.
The cmd is this black box where you can put commands in that only hackers use if they want to hack something xD
Here's a picture of the cmd on Windows:

CMD on Windows


How to open cmd:

  • On Windows click on the Windows icon, type "cmd" and press enter.
  • On mac press Command-space to launch Spotlight and type "Terminal", then double-click the search result

 

 

Now we know how to open cmd, but how do we run the .jar file?

  • First we need to navigate to the drive the jar file is in
  • The we need to navigate to the folder the jar file is in
  • Last we need to tell java to run the jar file

Let's start :)
(And don't forget to press enter between the steps to run the command you entered)

 

 

Step 1

To navigate to a drive on windows open the command prompt and type the name of the drive the file is in. If you're on mac you can skip this step

Example:

Spoiler

If the file is in C:/Users/yourUser/desktop/whatever type

c:

in the command prompt. If the file is in D:/ThisIsAFolder type

d:

etc.

 

 

Step 2

Navigate to the file. Type cd and the path in quotation marks. Example:

Spoiler
cd "C:/this/is/the/path/to/the/installer"

 

 

Step 3

Now we need to tell java to run the file. The command for this is

java -jar nameOfTheFile.jar

Example:

Spoiler

Our file is named 1.16-Server.jar, so we execute 

java -jar 1.16-Server.jar

If the name of our file would be 1.16 Server.jar we would need to use quotation marks because the name has spaces in it:

java -jar "1.16 Server.jar"

 

 

How does it work?

There are many commands that you can type into command prompt.
Some are from the cmd itself (drive: and cd) and some from other applications (java).
All these commands take options/arguments, these are separated by spaces.

Spoiler

The command drive: is a special command that doesn't take options/arguments. You use it like this:

<drive>:

<drive> is the drive you want to navigate to.

Spoiler

The command cd takes the path as option/argument. If the path has spaces inside, you need to use quotation marks, else the command thinks they are different arguments. You use it like this:

cd <pathWithoutSpaces>
cd "<pathWithSpaces>"

<pathWithoutSpaces> and <pathWithSpaces> is the path you want to navigate to.

Spoiler

The command java is a command from the application java and can take much options/arguments. For all parameters it can take look here. We want to use the -jar option and path argument to tell java to run a .jar file. Again, if the file has spaces inside, you need to use quotation marks, else the java command thinks they are different arguments. You use it like this:

java -jar <filenameWithoutSpaces.jar>
java -jar "<filenameWithSpaces.jar>"

<filenameWithoutSpaces.jar> and <filenameWithSpaces.jar> is the file name with .jar at the end you want to navigate to.

 

 

Now you've run the .jar file manually. Mostly you do this to get the output, so just copy it form the cmd with Ctrl+C

I hope this guide helped you :D

If you have any suggestions or questions, please tell me by replying to the topic!

Edited by OutCraft
Picture not working

Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can :D

Also: PLEASE use SPOILERS for logs!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.