-2

OK, so you can run something like

start iexplore

in cmd and have it run internet explorer.

Is there a way to allow the same sort of behavior with something like, javac.exe (or some other utility exe)?

I don't want to have to type

"C:\Program Files\Java\jdk1.8.0_31\bin\javac.exe"

to run javac every time I need to via CL.

2

2 Answers 2

2

I think you should simply add "C:\Program Files\Java\jdk1.8.0_31\bin\;" to the PATH environment variable.

To do this go to Control Panel > System and security > System -> Advanced System Settings -> Advanced -> Environment variables and there scroll to "PATH" variable and Edit it adding "C:\Program Files\Java\jdk1.8.0_31\bin\;" at the beginning.

As a final tip: I think you may also find useful a pair of answers to this Stackoverflow question.

1
  • If it is a common command I give it a unique variable. Then call it with %MYCMD% this avoids your path getting cluttered (decreasing the chance of duplicate exes too)
    – jiggunjer
    Jun 24, 2015 at 3:31
0

I personally prefer making a custom script for adding environmental variables like the one mentioned by danicotra. Manually adding (and remembering) them after a reinstallation, setting up a a new computer, etc.. can be pretty annoying. Especially when your custom EnVar paths get bigger and start including more tools. ie: more than one programming language or custom CLI tools gathered over time.

You can save the following as a .bat file and execute for automatically adding custom paths to the existing EnVars. Needs Admin privileges.

:: Set Path variable equal to existing path plus specified directory.
setx PATH "%PATH%;C:\Program Files\Java\jdk1.8.0_31\bin\;" /m

:: Add Custom path to existing envars
setx JAVA_PATH "C:\Program Files\Java\jdk1.8.0_31\bin\;" /m

Not the answer you're looking for? Browse other questions tagged .