Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a jar file to the environment variables windows 8

Tags:

java

windows

cmd

So I'm trying to add a jar file to the environment variables in windows so instead of running java c:\mega_long_file_path\filename.jar I can run filename

I tried adding ;c:\mega_long_file_path\filename.jar; to the PATH variable in Control Panel >System and Security > System > advance system settings > advance > environment variables and that didn't work , I'm positive I have done this before what am I missing?

like image 851
Morton Avatar asked Sep 17 '25 19:09

Morton


1 Answers

Make a batch file named filename.bat and put this line in it:

java -jar c:\mega_long_file_path\filename.jar

Then put this batch file into your PATH or update your PATH to point to the directory where you created it.

After that you should be able to run filename.

like image 194
Mathias Begert Avatar answered Sep 19 '25 08:09

Mathias Begert