Search code examples
scriptingcommandpromptj

Running J scripts via command prompt on Win 10


How can I run J scripts from the console (cmd.exe or Powershell).I tried to set the path to jconsole.exe in Environment Variables but when I tried to launch it via cmd.exe, I get an error message that 'jconsole' is not recognized as an internal command or... I have done this successfully in the past for different command line tools. Also, how do I set the default directory in J so that I don't have to type the full directory path every time I run a file.


Solution

  • jconsole.exe works just like any other application in that regard. Once you've added the path to the file in your PATH variable, you can run it in a cmd session without specifying the whole path.

    In my case, if I open cmd.exe and add the path to J binaries to my PATH (be sure not to add any quotes!):

    set PATH=%PATH%;C:\Program Files\j901\bin;
    

    Then check that it has been successfully added to the end by typing PATH and pressing Enter. Then I can successfully start J in that session by just typing jconsole.exe.

    Note that this will only work for the current instance of cmd.exe. If I want it be available every time I open a new cmd.exe session, the I'd add it to the Path variable for my User using the Environment Variables Settings.

    You mention that you've tried setting the path in Environment Variables, but it might be worth explicitly stating the directory where J is installed on your computer and what you've added to the PATH.

    Have you confirmed in your cmd.exe session, that the path has been successfully amended?