Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit 976b7d6

Browse files
author
Ruben Daniels
committed
Merge pull request #143 from c9/java_runner
Created Java runner doc
2 parents f3eaffa + bf6bdef commit 976b7d6

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/features/java_runner.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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.

templates/default/toc.jade

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
// a(href='zen_mode.html') Zen Mode
6161
li.nav-submenu-item
6262
a(href='custom_runners.html') Custom Runners
63+
ul
64+
li.nav-submenu-item
65+
a(href="java_runner.html") Making a Java Runner
6366
li.nav-section
6467
.nav-section-header
6568
a(href='javascript:void(0)') IDE Components

0 commit comments

Comments
 (0)