Setup
This guide will walk you through setting up JRECC for your local machine.
Create a configuration file
First, you need to create a configuration file. The location of the configuration file depends on your operating system:
- Windows:
C:\Users\<user>\AppData\Roaming\jrecc\jrecc.yml, or%APPDATA%\jrecc\jrecc.yml - MacOS:
/Users/<user>/Library/Application Support/jrecc/jrecc.yml - Linux:
~/.config/jrecc/jrecc.yml, or${XDG_CONFIG_HOME}/jrecc/jrecc.yml
The configuration file needs to contain at a minimum, the following entries:
license: # Your license key purchased from jrecc.net
remoteExecution:
url: # URL to your RE-API server
instanceName: # RE-API instance name
Create a project
Create a project configuration file
Next, lets create a project to use JRECC. Choose a directory for your project, e.g. example-project, and create a new
jrecc.yml file inside.
name: example-project
Executing the compiler
Next, let's run JRECC in this directory to verify that our configuration is loading correctly.
$ java -jar compiler-0.0.1.jar
Searching for project configuration in /home/user/.config/jrecc
Loading configuration from file /home/user/.config/jrecc/jrecc.yml
Searching for project configuration in /home/user/example-project
Loading configuration from file /home/user/example-project/jrecc.yml
License validated with ID <ID>
usage: compiler [-cp <path>] [-d <directory>] [-encoding <encoding>] [-g]
[--proc <arg>] [-release <release>] [-s <directory>] [-source
<release>] [-sourcepath <path>] [-target <release>] [-version]
We can see in the output that both our user and project configuration files are being loaded. Since we didn't provide any command line arguments to our compiler, just the usage was printed.
Compiling a simple Java program
Let's verify that we can successfully execute the compiler by building a simple Java program.
Create a new file, Main.java:
// Main.java
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Now lets compile this:
java -jar compiler-0.0.1.jar Main.java
The command will fail, with an error message depending on the remote execution environment that you are using. In this example, we are using BuildGrid, which fails with the following error:
bwrap: execvp javac: No such file or directory
The failure is due to the remote execution environment not being populated with the necessary files to successfully
execute javac. When no files are specified, the remote execution sandbox environment is completely empty. We need to
update our project configuration to include any files that we want to be available in the sandbox.
Adding files to the remote execution environment
Modify our project's jrecc.yml file to include the following configuration:
name: example-project
all:
include:
ubuntu:
type: archive
uri: https://cdimage.ubuntu.com/ubuntu-base/releases/noble/release/ubuntu-base-24.04.3-base-amd64.tar.gz
sandboxPath: /
baseDirectory: ''
sha256: 6bc2cde3930ad088b3bb46fa45279e96d25bc3810f209850ecbe4722711874f9
java:
type: archive
uri: https://download.java.net/java/GA/jdk24.0.2/fdc5d0102fe0414db21410ad5834341f/12/GPL/openjdk-24.0.2_linux-x64_bin.tar.gz
sandboxPath: /usr/lib/jvm/
baseDirectory: ''
sha256: 635050717feab0e4c283c8e90e79e944a2b65a3b6b21f1d37dcaadad4cc29548
environment:
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/usr/lib/jvm/jdk-24.0.2/bin
This configuration adds several files to our sandbox environment.
The first is Ubuntu 24.04.3, which will be the base operating system that will host our project.
Next, is OpenJDK 24.0.2, which will be the Java compiler that we will execute in the sandbox.
Finally, the PATH environment variable is set to include the default paths provided by Ubuntu, as well as OpenJDK 24.
Let's verify that we have our compiler set up by running javac -version in our sandbox.
java -jar compiler-0.0.1.jar -version
Output:
javac 24.0.2
Now let's try and build our simple Java program again.
```shell
java -jar compiler-0.0.1.jar Main.java
java Main.class
Output:
Hello World
We have successfully compiled a simple Java program using remote execution.