|
| 1 | + |
| 2 | +While there are currently no Java builders or runners out of the box, the process of making your own is very quick. |
| 3 | + |
| 4 | +##Creating a Java builder |
| 5 | + |
| 6 | +In the menu, go to Run > Build System > New Build System |
| 7 | + |
| 8 | +You may copy and paste the following code for your Java builder: |
| 9 | + |
| 10 | +```bash |
| 11 | +{ |
| 12 | + "cmd": [ |
| 13 | + "sh", |
| 14 | + "-c", |
| 15 | + "mkdir -p $OUT_DIR; find $SRC_DIR -name \"*.java\" -print | xargs javac -sourcepath $SRC_DIR -d \"$OUT_DIR\"; echo '\\033[01;34mDone!\\033[00m'" |
| 16 | + ], |
| 17 | + "info": "\\033[01;34mBuilding\\033[00m \\033[01;31m$project_name\\033[00m", |
| 18 | + "env": {"OUT_DIR": "$project_path\\.bin", "CLASSPATH" : "$OUT_DIR:$CLASSPATH", "SRC_DIR": "src"}, |
| 19 | + "selector": "source.java", |
| 20 | + "working_dir": "$project_path" |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +This code builds .java files from the src/ directory. If you are using a different directory to store your .java files, change the `SRC_DIR` to match that directory. |
| 25 | + |
| 26 | +Similarly, the output directory is set to the .bin/ directory in your workspace. If you'd like to change that, change the `OUT_DIR` (be sure to apply that same change in your custom runner file). |
| 27 | + |
| 28 | +To build with your new builder, go to your Java file then click Run > Build System > My Builder. The .class files are now in your chosen output directory. |
| 29 | + |
| 30 | +Note: |
| 31 | +"My Builder" is the default name for a new builder. You may change the filename of your builder, just be sure to select this new builder. The same will be true for your runner. |
| 32 | + |
| 33 | +##Creating a Java runner |
| 34 | + |
| 35 | +In the menu, go to Run > Run With > New Runner |
| 36 | + |
| 37 | +You may copy and paste the following code for your Java runner: |
| 38 | + |
| 39 | +```bash |
| 40 | +{ |
| 41 | + "cmd": [ |
| 42 | + "sh", |
| 43 | + "-c", |
| 44 | + "echo $file | sed -r 's/.*\\/src\\///g' | sed -r 's/\\.java//g' | sed -r 's/\\//\\./g' | xargs java" |
| 45 | + ], |
| 46 | + "info": "\\033[01;34mRunning\\033[00m \\033[01;31m$file_name\\033[00m\n", |
| 47 | + "env": {"OUT_DIR": "$project_path\\.bin", "CLASSPATH" : "$OUT_DIR:$CLASSPATH"}, |
| 48 | + "selector": "source.java", |
| 49 | + "working_dir": "$project_path" |
| 50 | +} |
| 51 | +``` |
| 52 | +To run your .class files with this new runner, go to your Java file then click Run > Run With > My Runner. |
0 commit comments