I have a Java Environment on C9. The Ace editor supports it nicely, but there's no run systems configured for it. I created my own which looks like this, the filename is JavaRunner.run:
// Create a custom Cloud9 runner - similar to the Sublime build system
// For more information see http://docs.c9.io:8080/#!/api/run-method-run
{
"cmd" : ["javac", "$file", "$args"],
"info" : "Started to compile java file at $project_path to ${file_base_name}.class",
"env" : {},
"selector" : "source.java"
}
On a second go, I tried this:
{
"cmd": ["javac $file_name && java $file_base_name"],
"info" : "In the directory of $file_path we will javac $file_name && java $file_base_name",
"working_dir": "$file_path",
"env" : {},
"selector" : "source.java",
"shell": true
}
The first example will do the compiling, but then it won't run the code. The second one works if it is run from the command line, but it won't work within the runner file.
To run multiple commands you'll need to wrap them in a bash shell. Here's an example of how the Node.js runner does it:
// This file overrides the built-in Node.js (default) runner
// For more information see http://docs.c9.io:8080/#!/api/run-method-run
{
"cmd": [
"bash",
"--login",
"-c",
"nvm use default > /dev/null; node ${debug?--nocrankshaft --nolazy --nodead_code_elimination --debug-brk=15454} '$file' $args"
],
"selector": "source.js",
"info": "Your code is running at \\033[01;34m$url\\033[00m.\n\\033[01;31mImportant:\\033[00m use \\033[01;32mprocess.env.PORT\\033[00m as the port and \\033[01;32mprocess.env.IP\\033[00m as the host in your scripts!\n"
}
This should work for your use case as well.