One of the more simple and robust ways to do what you want to do is by using the Terminus package. If you install that package, you gain access to the ability to open a terminal emulator directly inside of Sublime text.
One of the features of this is the ability to use it in a build system; the build will open a new Terminus tab, execute the build inside of it just like in a normal terminal, and then quit. One of the nice things about this is that you can also run programs that you need to manually interact with, which Sublime doesn’t support by default.
If you install Terminus, you could create a build system such as the following:
{
"target": "terminus_open",
"cmd": ["/Users/Documents/Code/bin/j", "$file"],
"working_dir": "${file_path}",
"auto_close": false,
"selector": "source.j"
}
This build will open a Terminus tab and execute the program inside of it. This video covers installing and using Terminus, including using it in a build system like this. A more expanded version of this topic can also be found in this video as well.
This is true of languages where there are a lot of preparatory steps to running the program, but it’s not always needed.
For example, in the C and C++ programming languages, you need to pass your program through a compiler to generate an object file, then run a separate tool to link that object file and the require libraries together in order to come up with the final executable, which you can then run.
If your program is made up of two or more files, then there’s no need to compile files that you haven’t modified because the result is going to be the same object file anyway. Similarly if you’re not actively modifying your program and just running it, then compiling and linking is also a waste of time because the executable isn’t going to change.
I’m not familiar with J as a programming language, but from a (little) google search it appears to be an interpreted language. In that case you pass your program source code to a an interpreter that compiles and runs it as one step (i.e. there are no intermediary files generated).
In such a case, I wouldn’t worry about trying to set something like this up because it would either be not possible or otherwise just not worth it.
If you want to set something like that up you need to know what commands you would use instead of the one you outlined in your original post to re-run a program without compiling it first. Once you know that you can augment your build system with a variant
so you can choose that one if you want to.
This video playlist covers the topic of build systems in Sublime text, from the simple to the more advanced, including a video on variants. The video mentioned above also appears here as well.