russellsayshi
russellsayshi

Reputation: 2569

Open jar file with cmd

I have a jar file named "adventure.jar". When you run it through the cmd with java -jar adventure.jar it works fine. However, I am testing opening the file on a new computer, and I am encountering a problem. This computer doesn't have the java command in the command prompt. It defiantly has Java installed, but maybe just not the JDK? Anyway, my goal is to make the jar file run from cmd when double clicked, without the need of commands (is that even possible?). The jar is already executable, but it doesn't execute from the command prompt like I need. Any help would be appreciated.

EDIT: If there is a way to do this through an exe or batch file I'd be fine with that, too.

Upvotes: 2

Views: 36678

Answers (3)

Mohit Singh
Mohit Singh

Reputation: 6167

Open command prompt

Go to the folde where jar file is located

Run

unzip test.jar

here test.jar is name of the jar file.

This command will unzip all the file into that folder

Upvotes: 0

BenjiWiebe
BenjiWiebe

Reputation: 2235

First, try start adventure.jar from Command Prompt. If that does not work, locate java.exe (on my computer, C:\Program Files\Java\jre7\bin) and either use the full path in Command Prompt, or add the path to the folder containing java.exe to your PATH environment variable. To add the path, click Start Menu, right-click Computer, click Properties, click Advanced System Settings, click Environment Variables, then find PATH under System Variables and click Edit, and add the path (example: add the following onto the end of PATH: ;C:\Program Files\Java\jre7\bin and don't forget the semicolon!)

Hope it helps.

Upvotes: -1

ddavison
ddavison

Reputation: 29042

Sounds like your PATH env. variable doesn't have Java in it. You can add it by following Oracle's tutorial

Adding Java to your PATH Environment variable.

Usually it's something like ;C:\Program Files\Java\jre7\bin

To your second question - yes it's possible.
Open up notepad, then type java -jar adventure.jar then save it as launch.bat or something. then you are able to double click that batch file, which will run your java archive.

Upvotes: 3

Related Questions